[R] "Read.csv" in R with dynamic file (1st) argument

Steven Kang
Thu, 10 Sep 2009 00:32:13 -0000

Dear R users,


I have numerous data sets (csv files) saved in the folder which has the same
name as individual data.
(i.e data x1 saved in x1 folder, data x2 in x2 folder etc)

I would like to read in the desired data set name using 'scan' function
and
assign this inputted value to an object so that it can be used in the
'read.csv' function.

For example,

x <- scan()
1: 0708
2:
Read 1 item

dat <- read.csv("D://R//Data//x//x.csv", head=TRUE, sep =
",")
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") :
  cannot open file ('D://R//Data//x//x.csv': No such file or directory


 In SAS, this can be done by assigning x as a macro variable, is there an
equivalent function in R?

Moreover, is there any way of using the inputted variable which starts with
number 0 (i.e 0102) in the 'read.csv' function?

Appreciate for providing your expertise in resolving this problem.

	[[alternative HTML version deleted]]