data-raw/aaaConvertCSV2RDATA.R

##############################################################
##                                                          ##
## Use this to convert comma separated values files (*.csv) ##
##   in the data-raw directory of the fishWiDNR package to  ##
##   R data files (.rdata) in the data directory of the     ##
##   same package.                                          ##
##                                                          ##
##############################################################

library(tools)

## Get all .csv files in the data-raw directory
setwd("C:/aaaWork/Programs/GitHub/fishWiDNR/data-raw")
raw <- list.files(pattern="*.csv")

#### Convert to .rdata files ####
## Cycle through each file to make it an RDA file
for (f in raw) {
  print(f)
  ## Read file
  nm <- file_path_sans_ext(f)
  assign(nm,read.csv(f,stringsAsFactors=FALSE))
  ## Save as an .rdata file
  save(list=nm,file=paste0("../data/",nm,".rdata"))
}
droglenc/fishWiDNR documentation built on May 15, 2019, 2:51 p.m.