[R] combine vector and data frame on field?

From: Karin Lagesen <karin.lagesen_at_medisin.uio.no>
Date: Tue, 26 Feb 2008 15:25:48 +0100

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

______________________________________________
R-help_at_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.
Received on Tue 26 Feb 2008 - 14:28:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Feb 2008 - 15:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive