0
我有一個數據幀,看起來像這樣:如何重塑這些數據來繪製ggplot2的多行?
lethal.y lethal.x resist.y resist.x mock.y mock.x
Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000
1st Qu.:0.3724 1st Qu.:0.4349 1st Qu.:0.6580 1st Qu.:0.3102 1st Qu.:0.5065 1st Qu.:0.5143
Median :0.6786 Median :0.8688 Median :0.9889 Median :0.6034 Median :0.9105 Median :0.9305
Mean :0.5943 Mean :0.6961 Mean :0.8086 Mean :0.5645 Mean :0.7337 Mean :0.7445
3rd Qu.:0.8229 3rd Qu.:0.9791 3rd Qu.:1.0000 3rd Qu.:0.8236 3rd Qu.:0.9863 3rd Qu.:0.9970
Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000
每個項目都有100行,而* .X和* .Y表示X,Y COORDS我想繪製每個這三個條件。
我想用ggplot2在不同顏色的線條上繪製這三個圖。我相信我需要融化()數據幀到類似:
variable x y
lethal .05 .01
lethal .03 .02
...
resist
...
mock
我只是不完全知道如何在這裏重塑數據。任何人都可以將我指向正確的方向嗎?謝謝!
按照要求,dput(頭(DF))
structure(list(lethal.y = c(1, 0.96880698743694, 0.943637604878407,
0.927797183915007, 0.913304798925335, 0.898733226540142), lethal.x =
c(0,
0.00188975165738148, 0.017044638907188, 0.0473993105875835,
0.0839965839587461,
0.123115782372135), resist.y = c(1, 1, 1, 1, 1, 1), resist.x = c(0,
0.0270024232342251, 0.0532702535247161, 0.0802380777311505,
0.106711277307466,
0.131788524427236), mock.y = c(1, 0.99663149455591,
0.994833858282874,
0.992162832558697, 0.9898151419445, 0.98845829511382), mock.x = c(0,
0.0422315106004306, 0.0848393643462402, 0.127812802135558,
0.17073684383134,
0.212410640574118)), .Names = c("lethal.y", "lethal.x", "resist.y",
"resist.x", "mock.y", "mock.x"), row.names = c(NA, 6L), class =
"data.frame")
請複製/ dput(頭(yourData))的輸出粘貼到你的問題,以創建樣本數據。 – www
當然,現在補充。 –
謝謝,這使得事情變得更容易,讓你得到快速準確的答案。 – www