[R] paste first row string onto every string in column

Jill Hollenbach jhollenbach at chori.org
Wed Aug 12 03:48:37 CEST 2009

I am trying to edit a data frame such that the string in the first line is
appended onto the beginning of each element in the subsequent rows. The data
looks like this:

> df
      V1   V2   V3   V4   
1   DPA1* DPA1* DPB1* DPB1*
2   0103 0104 0401 0601 
3   0103 0103 0301 0402 
 and what I want is this:

      V1   V2   V3   V4   
1   DPA1* DPA1* DPB1* DPB1* 
2   DPA1*0103 DPA1*0104 DPB1*0401 DPB1*0601 
3   DPA1*0103 DPA1*0103 DPB1*0301 DPB1*0402 

any help is much appreciated, I am new to this and struggling.

 Jill Hollenbach, PhD, MPH
    Assistant Staff Scientist
    Center for Genetics
    Children's Hospital Oakland Research Institute
    jhollenbach at chori.org

View this message in context: http://www.nabble.com/paste-first-row-string-onto-every-string-in-column-tp24928720p24928720.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list