I need to reshape this data below in long format stacking four columns A C G
and T
columns together. I have found many answers for two columns, but could not find for more than two columns.
mydata<- structure(list(Pos = 1:18, A = c(1.22050447518308, 0.976403580146461,
0.244100895036615, 0.081366965012205, 0.569568755085435, 0.32546786004882,
0.244100895036615, 0.32546786004882, 0.48820179007323, 0.732302685109845,
1.87144019528072, 1.05777054515867, 0.48820179007323, 0.32546786004882,
0.16273393002441, 0.65093572009764, 0.406834825061025, 18.5516680227827
), C = c(0.813669650122051, 0.65093572009764, 0.48820179007323,
0.32546786004882, 0.813669650122051, 0.976403580146461, 0.244100895036615,
2.27827502034174, 0.406834825061025, 0.895036615134255, 0.976403580146461,
0.244100895036615, 0.244100895036615, 0.244100895036615, 0.569568755085435,
0.569568755085435, 1.5459723352319, 5.20748576078112), G = c(1.13913751017087,
1.30187144019528, 0.813669650122051, 0.48820179007323, 1.13913751017087,
0.895036615134255, 5.93978844589097, 1.30187144019528, 0.569568755085435,
0.732302685109845, 0.569568755085435, 0.48820179007323, 0.48820179007323,
0.48820179007323, 0.732302685109845, 0.569568755085435, 1.70870626525631,
6.10252237591538), T = c(0.569568755085435, 0.16273393002441,
0.244100895036615, 0.32546786004882, 2.27827502034174, 0, 0.406834825061025,
0.081366965012205, 0.244100895036615, 0.244100895036615, 0.244100895036615,
0, 0.081366965012205, 0.16273393002441, 0.244100895036615, 0.48820179007323,
1.05777054515867, 21.4808787632221)), .Names = c("Pos", "A",
"C", "G", "T"), class = "data.frame", row.names = c(NA, -18L))