[R] Loop
Eik Vettorazzi
E.Vettorazzi at uke.de
Wed Feb 22 17:54:14 CET 2012
Hi Florian,
'yet that doesn't work' is an improper question on this list, see the
posting guide.
Besides that, something like
set<-vector(mode = "list", length = 10)
for (i in 1:10){
set[[i]] <- complete(imp,i)}
or saving some typing
set<-lapply(1:10,function(i)complete(imp,i))
should work.
cheers
Am 22.02.2012 11:32, schrieb Florian Weiler:
> Dear all,
>
> I have a (probably very basic) question. I am imputing data with the mice
> package, using 10 chains. I can then write out the 10 final values of the
> chains simply by
>
> name1 <- complete(imp, 1)
> :
> :
> name10 <- complete(imp,10)
>
> Not a big deal, I just wanted to do that in a little loop as follows:
>
> for (i in 1:10){
> set[i] <- complete(imp,i)}
>
> Yet that doesn't work, I also tried other things like:
> for (i in 1:10){
> set[[i]] <- complete(imp,i)}
>
> Again, no success. It only saves a couple of lines of code, but there must
> be an easy solution, right?
> Thanks,
> Florian
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Loop-tp4409865p4409865.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
--
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
--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG):
Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg
Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus
More information about the R-help
mailing list