[R] can rows of text be repeated using R to create a new datafile

From: Bob Green <bgreen_at_dyson.brisnet.org.au>
Date: Sat 08 Jul 2006 - 19:14:38 EST


I am hoping for some advice as to whether the following task can be performed in R?

I have a spreadsheet with 325 rows x 3 columns. The data was collected from 40 individuals who in most instances generated 8 bi-polar constructs (the poles are separated by //). The first column is the construct number = 1 to 325. The second is an id number =1 to 40; the third column is the data to be coded. Because persons 1, 18 & 40 generated 9 rows of data, and person 5, 10 rows; rows =325 not 320.

What I want to do is repeat each row a set number of times - hopefully 4 (the number of coders to code the data). Once repeated there would be 4 conids x 1 , 4 x 2 etc …. 4x 325.

Currently this is how the first 2 rows look:

conid	person	construct
1	1	offence against property  // offence against person
2	1	insight & cooperative with treatment //  lack insight

This is how I want them to look after editing.

conid	person	construct
1	1	offence against property  // offence against person
1	1	offence against property  // offence against person
1	1	offence against property  // offence against person
1	1	offence against property  // offence against person
2	1	insight & cooperative with treatment //  lack insight
2	1	insight & cooperative with treatment //  lack insight
2	1	insight & cooperative with treatment //  lack insight
2	1	insight & cooperative with treatment //  lack insight
2	1	insight & cooperative with treatment //  lack insight



Any assistance is much appreciated,

Bob



R-help@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 Received on Sat Jul 08 19:21:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 08 Jul 2006 - 22:15:45 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.