how to "singlify" entries
On 30 May 2005 at 21:56, Charles Plessy wrote:
On Mon, May 30, 2005 at 09:15:32AM +0000, zhihua li wrote :
hi netters I have a rather simple question. I have a data frame with two variables X and Y, both of which are factors. X has 100 levels while Y has 10 levels only. The data frame has 100 rows in all, so for X the values are unique, and Y has many replicate values. Now I wanna reduce the data frame into 10 rows only, according to the 10 levels of Y. I don't care which value of X is in the same row with Y in the final data frame, as long as it is in agreement with the original data frame.
Dear list, I am a new subscriber, using R to analyse genomics data. I have a similar question, maybe even identical, but I am not sure...
Hallo Me neither. ?reshape
dat<-read.table("clipboard", header=T)
dat
F1 F2 V 1 A X 3 2 A Y 6 3 B X 5 4 C X 9 5 C Y 3
reshape(dat, idvar="F1", timevar="F2",direction="wide")
F1 V.X V.Y 1 A 3 6 3 B 5 NA 4 C 9 3 Homework: change NA to zero. HTH Petr
From a data frame with two factors and one value, I would like to obtain a data
frame with one factor and one value per level in the removed factor. For instance: F1 F2 V ----------------- A X 3 A Y 6 B X 5 C X 9 C Y 3 Would become: F1 VX VY ------------------ A 3 6 B 5 0 C 9 3 I am sure I have seen a tool to do this some time ago, but I do not remember its name. Can somebody help me ? Best regards, -- Charles Plessy, Ph.D. - Genome Science Laboratory The Institute for Physical and Chemical Research (RIKEN) 2-1 Hirosawa, Wako, Saitama 351-0198, Japan plessy at riken.jp -- Fax: 048-462-4686 -- Tel: 048-467-9515
______________________________________________ R-help at 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
Petr Pikal petr.pikal at precheza.cz