Skip to content

Instantly share code, notes, and snippets.

@dlebauer
Created February 23, 2016 21:55
Show Gist options
  • Save dlebauer/15b588bf334334a34c31 to your computer and use it in GitHub Desktop.
Save dlebauer/15b588bf334334a34c31 to your computer and use it in GitHub Desktop.
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