[R] Odp: Save variable with loop part
Petr PIKAL
petr.pikal at precheza.cz
Mon Oct 15 13:01:58 CEST 2007
Hi
r-help-bounces at r-project.org napsal dne 15.10.2007 11:12:57:
> Hello
>
> does anyone know how to save in a variable with a loop part.
>
> Im reading several csv files with read.table and would like to save with
a loop:
>
> for (i in 0:9){
> }
>
> should give read0, read1, read2, read3, read4, read5, read6, read7,
read8, read9
>
> st. like read(i)<-read.table("myfile.csv".....)
Well this is not an answer to your question but did you consider to use
list? If your data are similar and you want to do some analysis with it
list seems to me as a better option than several objects.
read <- rep(vector("list", 1),9)
gives you an empty list
and
read[[1]] <- read.table(....
reads specified file to first position of list.
Be aware also that in R indexing starts at 1 not at 0.
Regards
Petr
>
> I tried with paste("read", i, sep"") or to save as a vector with my
names, but
> it doesn't work
>
> suggestions?
>
> thanks
>
> marc
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list