Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Created April 24, 2012 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhkeller/2480858 to your computer and use it in GitHub Desktop.
Save mhkeller/2480858 to your computer and use it in GitHub Desktop.
Create a new R dataframe from a subset of columns from another df
unique(df[, c("a", "c")])
or
df <- subset(df, select = c(a,c))
or to drop
df <- subset(df, select = -c(a,c))
where a,c don't need quote or can be written df$a,df$c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment