[英]R ggplot2: use one column as x-axis and the rest as y-axis
我有一個類似於以下的大 df
一種 | 乙 | C | D | 乙 |
---|---|---|---|---|
1 | 10 | 3 | 9 | 5 |
2 | 4 | 6 | 9 | 5 |
4 | 8 | 12 | 7 | 3 |
我正在嘗試制作一個散點圖,其中 A 列是 x 值,其余列中的所有值都是 y 值,每列都有不同的顏色。 我嘗試了以下操作,但收到錯誤Error: unexpected ']' in p1
p1 <- ggplot(data = df.p, aes(df.p, aes(x=colnames(df.p[1]), y = colnames(df.p[2:]), colour=df.p[2:]))) + geom_point() + scale_colour_identity()
我也試過x=get(colnames(df.p[1]))
和x=df.p[1]
但我總是得到同樣的錯誤
Error: At least one layer must contain all faceting variables: `variable`.
* Plot is missing `variable`
* Layer 1 is missing `variable`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.