I have this data below. I want to melt all No_of.reads
cloumns in one column and all _contamination_
columns in another column. So the final dataframe would have diluted_sample
, No_of_reads
and _contamination_
columns. I tried to do this in two steps, but this would give me repeated observations. What is the right way to do it?
code:
test.dput.melted <- melt(test.dput, id = 1:3, measure = 4:7)
test.dput.melted <- melt(test.dput.melted, id = c(1,4,5), measure = 2:3)
Data:
test.dput<- structure(list(diluted_sample = c("100%", "95%", "90%", "85%",
"80%", "75%"), No_of_reads_from_NA12878 = c("15,000,000", "14,250,000",
"13,500,000", "12,750,000", "12,000,000", "11,250,000"), No_of_reads_from_NA12877 = c("0",
"750,000", "1,500,000", "2,250,000", "3,000,000", "3,750,000"
), tEst_contamination_of_NA12878 = c("99.60%", "99.10%", "96.80%",
"92.60%", "88%", "82.60%"), pair_contamination_of_NA12878 = c("100.00%",
"94.15%", "88.72%", "83.36%", "78.20%", "73.08%"), tEst_contamination_of_NA12877 = c("0.10%",
"7%", "13.60%", "20.10%", "26.20%", "32.10%"), pair_contamination_of_NA12877 = c("0.10%",
"5.21%", "10.50%", "15.85%", "20.92%", "26.04%")), .Names = c("diluted_sample",
"No_of_reads_from_NA12878", "No_of_reads_from_NA12877", "tEst_contamination_of_NA12878",
"pair_contamination_of_NA12878", "tEst_contamination_of_NA12877",
"pair_contamination_of_NA12877"), row.names = c(NA, 6L), class = "data.frame")