[R] how can I write two objects together, problem with cbind()

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Feb 16 08:27:10 CET 2006


Srinivas Iyyer wrote:

> Hi Group,
>  I have two objects
> 1. A data.frame with 2 columns
> 
> Apple  4
> Boy    2
> Cat    5
> Dog    10
> Eel    9
> ...
> Zebra  10
> (26 rows)
> 
> I have another object which was obtained as vector of
> integers with names as character.
> 
> Fruit 10
> King 20
> Eel  19
> Boy 20
> Apple 15
> ...
> (26 rows)
> 
> Now I wanted to combine the two objects and wanted a
> result that would look like this:
> 
> Apple  4 15
> Boy    2 20
> Cat    5 28
> Dog    10 25
> Eel    9 19
> 
> 
> result <- cbind(obj1, obj2)
> 
> My result is now jumbled:
> 
> Apple  4 34
> Boy    2 21
> Cat    5 234
> Dog    10 23
> Eel    9  12
> 
> I want to write identical row names elements together.
> 
> 
> What could be done here. Could any one please help me.
> 


See ?merge

Uwe Ligges


> thanks
> Srini
> 
> ______________________________________________
> 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




More information about the R-help mailing list