Hello,

You are reading 11 times the same file, 'toread'.
Assuming that 'toread' is a vector with 11 different filenames in it, something like the following might do what you want.

for ( i in 1:11) myfiles[i] <- read.csv(toread[i], header = TRUE, sep=")

AS for the final "for loop", it does nothing. Why have you posted that ugly thing?

Hope this helps,

Rui Barradas

Em 17-06-2013 10:01, Dzu escreveu:
Dear R-help users,

I am quite new in R. I have multiple csv.files with different size. I would
like to read them by using a for- loop and parallel by reading I need to add
a new column which can be specified by myself.

But my for-loop does not work !
Could somebody give me any idea ?
Many thanks!

myfiles <-list()
for ( i in 1:11) myfiles[i] <- read.csv(toread,header = TRUE, sep=")
names(myfiles) <- paste(myfiles)
mytotalfiles <- myfiles

#sample the data by the number of the columns by adding a new column
sample(i1, 1000, replace = FALSE, prob = NULL)
for n <- 1000
sample <- myfiles[sample(nrow (df), 1000),]







--
View this message in context: 
http://r.789695.n4.nabble.com/Reading-multiple-csv-files-with-a-for-loop-tp4669681.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to