Created
March 6, 2020 03:01
-
-
Save ozjimbob/4abcf9999b9460b671385e83249355cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple tibble | |
d <- tibble(a1="foo", | |
a2="bar") | |
# Want to make a new column called "new" and unite all the "a*" columns together | |
newcol <- "new" | |
startchar <- "a" | |
unite(d,col=newcol,starts_with(startchar)) # Yay | |
# But what if we want to choose the column name from a vector? | |
newcol <- c("new","something_else") | |
unite(d,col=newcol[1],starts_with(startchar)) # Nope | |
# unite(col..) says it wants a "string" as the name of the new column | |
# How is the first element of a vector with strings in it not a string? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment