I have the following working code:
############################################
###Read in all the wac gzip files###########
###Add some calculated fields ###########
############################################
library(readr)
setwd("N:/Dropbox/_BonesFirst/65_GIS_Raw/LODES/")
directory<-("N:/Dropbox/_BonesFirst/65_GIS_Raw/LODES/")
to.readin <- as.list(list.files(pattern="2002.csv"))
LEHD2002<-lapply(to.readin, function(x) {
read.table(gzfile(x), header = TRUE, sep = ",", colClasses = "numeric", stringsAsFactors = FALSE)
})
But I would like to load the things from lapply into the global environment, for debugging reasons.
This provides a way to do so.
# Load data sets
lapply(filenames, load, .GlobalEnv)
But when I attempt to use it, I get the following error:
Error in FUN(X[[i]], ...) : bad restore file magic number (file may be corrupted) -- no data loaded In addition: Warning message: file ‘az_wac_S000_JT00_2004.csv.gz’ has magic number 'w_geo' Use of save versions prior to 2 is deprecated
Am I doing something wrong, or is 'load' deprecated or the like?
The gzfile(x) converts the .gz (zipped) file to a .csv so that shouldn't be an issue...