Hi Laszlo,
the "see also" part of ?assign comes in use here, it leads to "get"

get(paste("df",i,sep=".")

Cheers

Am 21.03.2011 17:14, schrieb Bodnar Laszlo EB_HU:
> Hello everyone,
> 
> 
> 
> I'd like to ask you a question again, basically focusing on referring to 
> different objects.
> 
> 
> 
> Let's suppose we create the following databases this way:
> 
> 
> 
> id <-c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3)
> 
> a <-c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3)
> 
> b <-c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2)
> 
> c <-c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2)
> 
> d <-c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2)
> 
> e <-c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,4)
> 
> df <-data.frame(id,a,b,c,d,e)
> 
> df
> 
> 
> 
> for (i in 1:3) assign(paste("df", i, sep="."), split(df,df$id)[[i]])
> 
> df.1
> 
> df.2
> 
> df.3
> 
> 
> 
> Now in the next step I'd like to get or "recall" these databases but not just 
> simply sending 'df.1', 'df.2', 'df.3' to R (because my real df database is 
> much bigger and much more complicated than this simplified one as usual). I 
> would have liked to do this the similar way you recall these things in Excel 
> Visual Basic.
> 
> 
> 
> You know, if we were in an Excel VB world I would do something like:
> 
> sub exercise ()
> 
> for i = 1 to 3
> 
>                 df.i
> 
>                 // perform this and that etc.//
> 
>         next i
> 
> end sub
> 
> 
> 
> Returning to R: first I wanted to do it this way:
> 
> for (i in 1:3)
> 
>     df.i (perform this and that etc...)
> 
> 
> 
> But of course it is wrong. Is there a proper way to handle this one? What do 
> I miss? I do not know if my question is clear...
> 
> Thank you very much and thanks for the previous answers as well!
> 
> Happy R-exploring!
> 
> Laszlo
> 
> 
> 
> ____________________________________________________________________________________________________
> 
> Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy 
> jogilag, szakmailag vagy más módon védett információt tartalmazhat. 
> Amennyiben nem Ön a levél címzettje akkor a levél tartalmának közlése, 
> reprodukálása, másolása, vagy egyéb más úton történő terjesztése, 
> felhasználása szigorúan tilos. Amennyiben tévedésből kapta meg ezt az 
> üzenetet kérjük azonnal értesítse az üzenet küldőjét. Az Erste Bank Hungary 
> Zrt. (EBH) nem vállal felelősséget az információ teljes és pontos - 
> címzett(ek)hez történő - eljuttatásáért, valamint semmilyen késésért, 
> kapcsolat megszakadásból eredő hibáért, vagy az információ felhasználásából 
> vagy annak megbízhatatlanságából eredő kárért.
> 
> 
> 
> Az üzenetek EBH-n kívüli küldője vagy címzettje tudomásul veszi és 
> hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH 
> folytonos munkamenetének biztosítása érdekében.
> 
> 
> 
> 
> 
> This e-mail and any attached files are confidential and/...{{dropped:19}}
> 
> 
> 
> 
> ______________________________________________
> 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.

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

______________________________________________
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