Created
February 23, 2016 21:55
-
-
Save dlebauer/15b588bf334334a34c31 to your computer and use it in GitHub Desktop.
restore species to usda plants: code for https://github.com/USDA/USDA-APIs/issues/7#issuecomment-187791953
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
library(data.table) | |
species <- fread('species.csv') | |
## identify and remove records that were present when we imported the table | |
usdaplants <- species[!is.na(NativeStatus) ] | |
## data table method of renaming columns | |
setnames(usdaplants, | |
old = c('id', 'genus', 'species', 'scientificname', 'commonname'), | |
new = c('betydb.species.id', 'Genus', 'Species', 'ScientificName', 'CommonName')) | |
## data table method of deleting rows | |
usdaplants[, spcd:=NULL] | |
write.csv(usdaplants, file = 'usdaplants.csv') | |
save(usdaplants, file = 'usdaplants.RData') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment