[R] combine vector and data frame on field?

Karin Lagesen karin.lagesen at medisin.uio.no
Tue Feb 26 15:25:48 CET 2008


I have managed to create a data frame like this:


> tsus_same_mean[1:10,]
     PID            Grp        Dist   PercAln    PercId
1  12638  Acidobacteria 0.000000000 1.0000000 1.0000000
2     87 Actinobacteria 0.000000000 0.9700000 0.9700000
3     92 Actinobacteria 0.008902000 1.0000000 0.9910000
4     94 Actinobacteria 0.000000000 1.0000000 1.0000000
5    189 Actinobacteria 0.005876733 0.9733333 0.9676667
6    242 Actinobacteria 0.001734200 0.9733333 0.9715333
7    305 Actinobacteria 0.000000000 0.9700000 0.9700000
8    307 Actinobacteria 0.000000000 0.9700000 0.9700000
9    328 Actinobacteria 0.000000000 1.0000000 1.0000000
10 10689 Actinobacteria 0.000000000 1.0000000 1.0000000
> 

and what I think is a factor like this:

> tsuPIDCount[1:10]
 3  4  5  8  9 12 13 15 18 19
 2  2  2  3  4  7  4  2  2  3
>

Now, I'd like to combine the two. The factor levels in tsuPIDCount
corresponds to the field called PID in the data frame.

Any hints on how to do this? cbind just adds the vector onto the end,
and I couldn't quite figure out if I could somehow say that the level
should correspond to the PID.

Thanks a lot for your helpin advance:)

Karin
-- 
Karin Lagesen, PhD student
karin.lagesen at medisin.uio.no
http://folk.uio.no/karinlag



More information about the R-help mailing list