[R] merging a dataframe or vectors

David Winsemius dwinsemius at comcast.net
Wed Mar 13 18:31:45 CET 2013


On Mar 13, 2013, at 6:11 AM, Al Ehan wrote:

> Hi,
> 
> I would like to know what is the easiest way to compile two or more set of
> vectors or data frame, according to their index. They are interrelated to
> one another by their assigned index. for example:
> 
> #data set 1
> abc
> #output:
>  X403   X408   X410   X415   X418   X419   X420   X423   X424   X425
> X426   X427
> 549.58 541.91 544.18 549.37 555.54 540.83 543.26 544.26 546.85 548.98
> 553.10 556.49
>  X428
> 543.57
> 
> #data set2
> def
> #output:
> X401   X402   X404   X405   X406   X407   X409   X411   X412   X413   X414
>  X416
> 528.46 524.15 527.18 526.04 533.71 537.79 536.80 532.38 517.14 529.32
> 523.29 539.58
> X417   X421   X422   X429
> 535.38 532.68 515.28 523.10

Why wouldn't you just use:

abcdef <- c(abc, def)
abcdef[order(names(abcdef))]

> 
> Both are numeric values and have indeces above each of the numbers which
> referring to X401 to X429 indices. I would like to combine both by sorting
> X401, X402,X403 and so on. Could somebody please help me before I waste my
> time using excel to do this. Thanks!
> 

> 	[[alternative HTML version deleted]]
> 
||||||||||||||||||||
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
^^^^^^^^^^^^^^^^^^^^

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list