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. Any help would be greatly appreciated Dean
On Jan 31, 2011, at 4:49 PM, 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)R code to create a matix would use the matrix function,>> for (j in list(3,91)) > + {M[,(j-2)]<-pic(datain[,j], mytree)} >You seem to be coming from a programming paradigm tha t uses "," where R would use ":" list(3,91) is a two element object rather than 3:91 which would be an 89 element object. Perhaps you should read some introductory material and get a better handle in the R syntax through self study. http://cran.r-project.org/doc/manuals/R-intro.pdf> datain is a matrix (11,91). I only want to use the pic() function on > the columns 3:91.What pic function??? > ?pic No documentation for 'pic' in specified packages and libraries: you could try '??pic'> When I use this code output is stored into the 1st column of M and the > 89th column of M but no other columns. > > Any help would be greatly appreciated > > DeanDavid Winsemius, MD West Hartford, CT
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.