Last active
September 9, 2015 05:19
-
-
Save nelsonauner/74b82300880159686682 to your computer and use it in GitHub Desktop.
Remove NAs only from certain columns with regex
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
#joinedData is dataframe | |
# has names(joinedData) > c("BLAH","BLEH","BLUCH","2015-05","2015-06",...) | |
# want to replce NAs with 0s for date columns | |
r <- "\\d{4}.\\d{2}" | |
x <- joinedData[grep(r,names(joinedData))] | |
x[is.na(x)] <- 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment