[R] paste function by INDICES

From: Massimiliano Tripoli <massimiliano.tripoli_at_gmail.com>
Date: Wed, 27 Apr 2011 16:34:51 +0200


Dear all,
I have the following R dataframe:

  set.seed(11)
   (df <- data.frame(ID=rep(1:10,1:10),a=factor(sample(1:4,55,rep=T)) ))    where ID is an identification code.
   I need to create a new variable "b" in which I would paste the full group of "a" variable according to ID variable.

   For example for ID=2 "b" should be 13, for ID=3 "b" should be 114, and for ID=4 should be 1241.
  How can I do that ?
  Thank you for any advices,
  Regards,
   Massimiliano Tripoli

        [[alternative HTML version deleted]]



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 Wed 27 Apr 2011 - 15:06:07 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 Wed 27 Apr 2011 - 16:00:34 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