错误:`data`必须是数据帧,或可由`fortify()`强制的其他对象,……您是否意外地将`aes()`传递给`data`参数?
我有这些数据错误:`data`必须是数据帧,或可由`fortify()`强制的其他对象,……您是否意外地将`aes()`传递给`data`参数?,r,ggplot2,bar-chart,R,Ggplot2,Bar Chart,我有这些数据 > Social_Split V1 Facebook 220 Instagram 213 Linkedin 73 None 3 Quora 44 Reddit 116 Signal 10 Snapchat 104 TikTok 88 Twitter 129 > str(Social_Split) 'data.frame': 10 obs. of 1 variable: $ V1:
> Social_Split
V1
Facebook 220
Instagram 213
Linkedin 73
None 3
Quora 44
Reddit 116
Signal 10
Snapchat 104
TikTok 88
Twitter 129
> str(Social_Split)
'data.frame': 10 obs. of 1 variable:
$ V1: num 220 213 73 3 44 116 10 104 88 129
我试图用ggplot绘制一个简单的水平条形图,所以我写了这段代码
gg_barplot <- ggplot(df=Social_Split, aes(x=Social_Split$V1))+
geom_bar("bin")
gg_barplot+coord_flip()
我们需要将列名指定为unquote
library(dplyr)
library(ggplot2)
Social_Split %>%
rownames_to_column('rn') %>%
ggplot(aes(x = rn, y = V1)) +
geom_col()
-输出
或者使用
base R
barplot(t(Social_Split))
数据
Social\u Split很好用。谢谢我能问你一个问题吗?是否有一个论点可以增加,使垃圾箱的大小变小,如更薄?我使用的是barplot(),我还想更改顺序,并根据数字进行升序或降序
barplot(t(Social_Split))
Social_Split <- structure(list(V1 = c(220L, 213L, 73L, 3L, 44L, 116L, 10L, 104L,
88L, 129L)), class = "data.frame", row.names = c("Facebook",
"Instagram", "Linkedin", "None", "Quora", "Reddit", "Signal",
"Snapchat", "TikTok", "Twitter"))