R version 3.2.4 "very secure dishes" on Ubuntu 14.04 LTS, how can I open a file given by an user in a function? -
i quite new in stackexchange , in r. following course on r, , assignment have series of more 300 files. have create function takes nb of files argument in vector (here id) : myfunction<-function(directory, variable, id=1:332)
. files in .csv format , called 001.csv until 332.csv.
my question how open given file nb of file number in id. instance, if call myfunction(directory, variable, 1)
, open first file (001.csv), etc. if call myfunction(directory, variable, 1:4)
, program open 4 first files. here attempt, doesn't work:
myfunction<-function(directory, variable, id=1:332) { for(i in id) { data<-read.csv("i.csv") } #data<-read.csv("") }
i precise question first step of function have write , not whole assignment ;) !
use paste0()
.
data <- read.csv(paste0(directory, "/", i, ".csv"))
Comments
Post a Comment