Hi all, I have a dataframe of rownames that I would like to extract from a larger matrix to form a new matrix. I have tried to use subset, in this manner x<-subset(largematrix, rownames$names=largematrix$rownames) where largematrix is the larger matrix and rownames$names is the dataframe with the row names of the rows I want to extract from the larger matrix. Of course, I get error messages. Any suggestions how I should proceed? Thanks Wade
try: x<-subset(largematrix, rownames$names %in% largematrix$rownames) On 7/28/06, Wade Wall <wade.wall@gmail.com> wrote:> > Hi all, > > I have a dataframe of rownames that I would like to extract from a > larger matrix to form a new matrix. I have tried to use subset, in > this manner > > x<-subset(largematrix, rownames$names=largematrix$rownames) > > where largematrix is the larger matrix and rownames$names is the > dataframe with the row names of the rows I want to extract from the > larger matrix. > > Of course, I get error messages. Any suggestions how I should proceed? > > Thanks > > Wade > > ______________________________________________ > R-help@stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
Hi all, I have a set of points (1...n) each of them defined on a 3D space (i.e. for each point I do have x,y,z coordinates), and I would like to generate a mean pairwise geometrical distance between them. Is there anyway I can do this with R? Conceptually is really simple. First I have to generate a distance matrix (let's say "distmat") of pairwise distances (d= sqrt((x1-x2)^2 + (y1-y2)^2+(z1-z2)^2) and then calculate the mean -- mean.matrix (distmat) -- . However, I do not know how I can generate the distance matrix using R. I'd really appreciate all your suggestions/comments. So, I have x y z 1 x1 y1 z1 2 x2 y2 z2 : : : : n xn yn zn and need 1 2 .. n 1 - 2 d12 - : n d1n d2n - So I can calculate mean din Thanks in advance!!!!! Best, /Jose