[R] Replicating Rows

From: <mwittmann_at_bren.ucsb.edu>
Date: Wed, 07 May 2008 20:41:51 -0700

Hi,

 I have a data matrix in which there are 1000 rows by 30 columns. The first column of each row is a numeric indicating the number of trips taken to a particular location with location attributes in the following column entries for that row.

I want to repeat each row based on the number of trips taken (as indicated by the number in the first column)...i.e., if 1,1 indicates 4 trips, I want to replicate row 1 four times, and do this for each entry of column 1.

I have played with rep command with little luck. Can anyone help? This is probably very simple.

Thank you,

mw

Marion Wittmann, Ph.D. candidate
Environmental Science and Management
University of California
Santa Barbara, CA 93106-5131



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 Thu 08 May 2008 - 03:54:34 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 Thu 08 May 2008 - 06:30:39 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