list - Executing two commands into one command in R -


i have 12 files in directory folder, type of files csv , sas7dbat. used command upload them:

filelist1 = list.files(path=".", pattern=".csv")  filelist2 = list.files(path=".", pattern=".sas")  

i tried write command, didn't go well:

filelist = list.files(path=".", pattern= c(".csv", ".sas")  

in addition, need 2 make them 1 command:

  list2env( lapply(setnames(filelist1, make.names(paste(2008:2016, "_kvish_1_10t",   sep= ""))),        read.csv), envir = .globalenv)  list2env( lapply(setnames(filelist2, make.names(paste0(2005:2007, "_kvish_1_10t", sep= ""))),        haven::read_sas), envir = .globalenv) 

pattern takes 1 argument.

if want find several elements, should try regex :

filelist <- list.files(path=".", pattern= "\\.csv|\\.sas") 

best,

colin


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -