[R] Storing loop output in matrix

Peter Ehlers ehlers at ucalgary.ca
Mon Jan 31 23:55:47 CET 2011


On 2011-01-31 13:49, Dean Castillo wrote:
> Hello
> I am trying to store output from a loop into an empty matrix. The
> current code I am using is:
>> M<-mat.or.vec(11,89)
>> for (j in list(3,91))
> + {M[,(j-2)]<-pic(datain[,j], mytree)}
>
> datain is a matrix (11,91). I only want to use the pic() function on
> the columns 3:91.
> When I use this code output is stored into the 1st column of M and the
> 89th column of M but no other columns.

Have you checked what list(3,91) produces?
Hint: help(seq)

Peter Ehlers

>
> Any help would be greatly appreciated
>
> Dean
>
> ______________________________________________
> 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