Hi Henri-Paul,

Try ("x" is your data):

x[rep(1:nrow(x), each = 6),]

HTH,
Jorge


On Thu, Aug 25, 2011 at 3:22 PM, Henri-Paul Indiogine <> wrote:

> Greetings!
>
> I am just now learning to use R for my dissertation project.   I need
> to manipulate a lot of text and numeric data.  I created a data frame
> that has 7 columns and 127 unique rows.  Now I need to replicate each
> line 6 times and then later change values in the first 2 columns.
>
> I am trying to figure out how to accomplish this.  I think that I need
> to use rep(my.df, each=6) but it does not quite work.
>
> This is the sample data frame
>
> "col1" "col2" "col3" "col4" "col5" "col6" "col7"
> foo      bar    1        blah   blah   blah   blah
> foo      bar    2        blah   blah   blah   blah
> foo      bar    3        blah   blah   blah   blah
> ......
> ......
>
>
> I need to change it into this:
>
> "col1" "col2" "col3" "col4" "col5" "col6" "col7"
> foo      bar    1        blah   blah   blah   blah
> foo      bar    1        blah   blah   blah   blah
> ....
> foo      bar    1        blah   blah   blah   blah
> foo      bar    2        blah   blah   blah   blah
> foo      bar    2        blah   blah   blah   blah
> ....
> foo      bar    2        blah   blah   blah   blah
> foo      bar    3        blah   blah   blah   blah
> foo      bar    3        blah   blah   blah   blah
> ....
> foo      bar    3        blah   blah   blah   blah
> .....
> .....
> and so on.
>
> Thanks!
>
> Henri-Paul
>
>
>
> --
> Henri-Paul Indiogine
>
> Curriculum & Instruction
> Texas A&M University
> TutorFind Learning Centre
>
> Email: hindiog...@gmail.com
> Skype: hindiogine
> Website: http://people.cehd.tamu.edu/~sindiogine
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to