Skip to content

Instantly share code, notes, and snippets.

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/2591271 to your computer and use it in GitHub Desktop.
Save mhkeller/2591271 to your computer and use it in GitHub Desktop.
Nice for grouping and summing in R
df <- read.csv("data.csv")
df$new_column1<- ifelse(df$c3 == "A",1,0)
df$new_column2<- ifelse(df$c4 == "B",1,0)
df$new_column3 <-ifelse(df$c5 == "C" & df$c6 = D, 1, 0)
via @BrianAbelson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment