Hi r-help-boun...@r-project.org napsal dne 17.09.2009 04:14:24:
> Hi, > > I want to construct a data.frame 'y' by using x$x and x$y. I think > that there might be better ways to do it (because, for example, we can > use a_matrix[3:5,] to extract certain rows, where 'a_matrix' is a > matrix). Can somebody let know what the best way is? > > > a=data.frame(x=1:10,y=rep("abc",10),z=rep("xyz",10)) > > a > x y z > 1 1 abc xyz > 2 2 abc xyz > 3 3 abc xyz > 4 4 abc xyz > 5 5 abc xyz > 6 6 abc xyz > 7 7 abc xyz > 8 8 abc xyz > 9 9 abc xyz > 10 10 abc xyz > > b=data.frame(x=a$x, y=a$y) > > b what is wrong on b[1:2,] Regards Petr > x y > 1 1 abc > 2 2 abc > 3 3 abc > 4 4 abc > 5 5 abc > 6 6 abc > 7 7 abc > 8 8 abc > 9 9 abc > 10 10 abc > > > > Regards, > Peng > > ______________________________________________ > 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. ______________________________________________ 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.