Skip to content

Instantly share code, notes, and snippets.

@dgrtwo
Last active November 25, 2015 17:34
Show Gist options
  • Save dgrtwo/d9e30155531799d3e984 to your computer and use it in GitHub Desktop.
Save dgrtwo/d9e30155531799d3e984 to your computer and use it in GitHub Desktop.
library(readr)
library(dplyr)
start <- read_delim("col3 col2 col4 col1
h a t t
i v i g
k s g n
n g n i", delim = " ")
start %>%
slice(c(1, 3, 2, 4)) %>%
select(col1, col3, col2)
### puzzle 2:
start2 <- read_delim("col3 col2 col4 col1
h b t t
i w i g
k t g n
n h n i", delim = " ")
# missing "a", "s", and "v", gotta use mutate:
start2 %>%
slice(c(1, 3, 2, 4)) %>%
select(col1, col3, col2) %>%
mutate(col2 = c("a", "s", "v", "g"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment