Break the repeated col. values into same col vertically displaying the output in R
1
0
Entering edit mode
3.7 years ago

New to R,using VCFR package. I have to break the repeated col. values into same col vertically displaying the output.

Sample Chr p-value AF MQ   Sample Chr p-value AF MQ   Sample Chr p-value AF MQ
A1      1  0.0533  30 40     A1    1  0.0633  35 45    A1     2  0.0753  35 45

I am trying to get the output,
Sample    Chr    p-value    AF     MQ
A1         1     0.0533     30     40
A1         1     0.0633     35     45
A1         2     0.0753     35     45
.......
.....
..


So on ..

I am using VCFR package to Read VCF Files and splitting their info field.

R vcf dataframe matrix • 649 views
1
Entering edit mode
3.7 years ago
rbind(d[,c(1:5)], d[,c(6:10)], d[,c(11:15)])

0
Entering edit mode

Thanks Ryan, I'll try this also. But, assume if we have "n" nu of cols then how to use .. ? I have shown only 5 cols, in some case there will be more than 40/50 cols and this is dynamic..

Also, can u pls say what is "c" and "d" ?

Thanks ..

0
Entering edit mode

d is your data frame, c is the standard R c function for defining vectors. For a dynamic number, I'd probably just create a string and eval() it. I'm sure there's a much more elegant way to do that, but it's simple to implement.

0
Entering edit mode

Can you pls update your script once ?

0
Entering edit mode

You can try to figure that our yourself first.