HI, R user, I generate the vectors with the same length. I want to put each vector into each column of data frame. Why it doesnt work`? rm<-data.frame() for(a in 1:6){ rm[,a]<-getmeasure(p1,a,speech) } thanks a lot Tammy _________________________________________________________________ Share your memories online with anyone you want. http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 [[alternative HTML version deleted]]
Try doing somthing like this : #your vector1 & 2 vect1 <- 2:5 vect2 <- c(3,1,6,4) # put both vectors in data.frame combVect <- data.frame(vect1=vect1, vect2=vect2) Note : 1) I suggest to avoid naming objects with names of already existing functions like "rm" 2) In R it is usually helpful to see your data as vetors and this way you can avoid for for() loop 3) Have also a look at the R-Wiki ( http://wiki.r-project.org/rwiki/doku.php ) and the other documents on www.r-project.org : There are some very good tutorials about the different types of data-structures and objects in R (and their use) !!! Wolfgang Tammy Ma a ?crit :> HI, R user, > > I generate the vectors with the same length. I want to put each vector into each column of data frame. Why it doesnt work`? > > rm<-data.frame() > > for(a in 1:6){ > rm[,a]<-getmeasure(p1,a,speech) > > } > > thanks a lot > > Tammy >. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et G?nomique Int?gratives CNRS UMR7104, IGBMC, 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3300 Fax (+33) 388 65 3276 wolfgang.raffelsberger (a t) igbmc.fr
Hi r-help-bounces at r-project.org napsal dne 01.09.2009 10:39:42:> > HI, R user, > > I generate the vectors with the same length. I want to put each vectorinto> each column of data frame. Why it doesnt work`? > > rm<-data.frame() > > for(a in 1:6){ > rm[,a]<-getmeasure(p1,a,speech) > > }Well, couldn't it be because function getmeasure does not exist? Error: could not find function "getmeasure" and you get another error rm[,a] Error in `[.data.frame`(rm, , 1:2) : undefined columns selected If you need to put a vector to data frame you shall preassign the structure, columns and rows. Or you can use list and as.data.frame Regards Petr> > thanks a lot > > Tammy > > > _________________________________________________________________ > Share your memories online with anyone you want. >http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1> [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Well the data frame has dimensions 0,0, to start with. Try dim(rm) What is "getmeasure" and what is it supposed to do? # btw rm is NOT a good name since it also is a reserved word in R. It removes objects. To create a data.frame of your six vectors why not just say mydata <- data.frame(V1, V2, V3, V4, V5, V6) --- On Tue, 9/1/09, Tammy Ma <metal_licaling at live.com> wrote:> From: Tammy Ma <metal_licaling at live.com> > Subject: [R] data frame > To: r-help at r-project.org > Received: Tuesday, September 1, 2009, 4:39 AM > > HI, R user, > > I generate the vectors with the same length. I want to put > each vector into each column of data frame. Why it doesnt > work`? > > rm<-data.frame() > > for(a in 1:6){ > rm[,a]<-getmeasure(p1,a,speech) > > } > > thanks a lot > > Tammy > > > _________________________________________________________________ > Share your memories online with anyone you want. > http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 > ??? [[alternative HTML version deleted]] > > ______________________________________________ > 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. >__________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com.