[R] merge, cbind, or....?

Bruno Cutayar bcutayar at lfdj.com
Fri Jul 23 17:07:16 CEST 2004



Hi,
i have two data.frame x and y like :
 > x <- data.frame( num = c(1:10), value = runif(10) )
 > y <- data.frame( num = c(6:10), value = runif(5) )
and i want to obtain something like :

 num.x    value.x     num.y   value.y
      1 0.38423828    NA 0.2911089
      2 0.17402507    NA 0.8455208
      3 0.54443465    NA 0.8782199
      4 0.04540406    NA 0.3202252
      5 0.46052426    NA 0.7560559
      6 0.61385464     6 0.2911089
      7 0.48274968     7 0.8455208
      8 0.11961778     8 0.8782199
      9 0.64531394     9 0.3202252
    10 0.92052805    10 0.7560559

with NA in case of missing value for y to x.

{ for this example : i write simply
 > data.frame(num.x=c(1:10), 
value.x=x[[2]],num.y=c(rep(NA,5),6:10),value.y=y[[2]]) }

I didn't find solution in merge(x,y,by="num") : missing rows are no keeping.
Can't you help me ?

thanks,
Bruno



Si vous n'etes pas destinataires de ce message, merci d'avertir l'expediteur de l'erreur de distribution et de le detruire immediatement.
Ce message contient des informations confidentielles ou appartenant a La Francaise des Jeux. Il est etabli a l'intention exclusive de ses destinataires. Toute divulgation, utilisation, diffusion ou reproduction (totale ou partielle) de ce message ou des informations qu'il contient, doit etre prealablement autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne peut etre assuree. La Francaise des Jeux decline toute responsabilite au titre de ce message s'il a ete modifie ou falsifie.

If you are not the intended recipient of this e-mail, please notify the sender of the wrong delivery and delete it immediately from your system.
This e-mail contains confidential information or information belonging to La Francaise des Jeux and is intended solely for the addressees. The unauthorised disclosure, use, dissemination or copying (either whole or partial) of this e-mail, or any information it contains, is prohibited.
E-mails are susceptible to alteration and their integrity cannot be guaranteed. La Francaise des Jeux shall not be liable for this e-mail if modified or falsified.




More information about the R-help mailing list