Re: [R] combine vector and data frame on field?

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Tue, 26 Feb 2008 12:01:35 -0300

Try this:

merge(tsus_same_mean, as.data.frame(tsuPIDCount), by.x="PID", by.y=0)

On 26/02/2008, Karin Lagesen <karin.lagesen_at_medisin.uio.no> wrote:
>
> 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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
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 - 15:07:03 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 - 16: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