Created
September 16, 2015 15:10
-
-
Save mhweber/07cf6548b7fb0ee26b68 to your computer and use it in GitHub Desktop.
A reminder snippet on how to recode a data frame variable based on pattern matching another variable in the same data frame
This file contains 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
x = c("AA","BB","A:B", "CC","C:A") | |
df = data.frame("ID" = x) | |
df | |
df$colons[grep(":", df$ID)] ='yes' | |
df$colons[is.na(df$colons)] ='no' | |
df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment