[R] how to "singlify" entries

Charles Plessy charles-r-nospam at plessy.org
Mon May 30 14:56:57 CEST 2005


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...

>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




More information about the R-help mailing list