Please I have some data arranged in rows and I would like to organize these lines in columns using "R" as follows:
The idea is to get "Allele, Effect and Obs" lines, which are arranged in 3 rows turning to columns. tag, Trait, Marker Locus are the same each three lines, what changes is the Allele, Effect and Obs.
Exemple: Initial data
data1 <-"tag Trait Marker Locus Site Allele Effect Obs
ca-S10_17086845 ca S10_17086845 10 17086845 R 0.000001 54
ca-S10_17086845 ca S10_17086845 10 17086845 A 3.489820 1
ca-S10_17086845 ca S10_17086845 10 17086845 G -0.017141 389
cf-S10_9890328 cf S10_9890328 10 9890328 R 0.000001 146
cf-S10_9890328 cf S10_9890328 10 9890328 G 4.367540 1
cf-S10_9890328 cf S10_9890328 10 9890328 A -0.010635 297"
data1 <-read.table(text=data1,header=T)
Expected outcome
data2 <- "Trait Marker Allele Ef1 Ef2 Ef3 Obs1 Obs2 Obs3
ca S10_17086845 R/A/G 0.000001 3.489820 -0.017141 54 1 389
cf S10_9890328 R/G/A 0.000001 4.367540 -0.010635 146 1 297"
data2 <-read.table(text=data2,header=T)
Thank you