Error: `data` must be a data frame, or other object coercible by `fortify()`,...Did you accidentally pass `aes()` to the `data` argument?

Error: `data` must be a data frame, or other object coercible by `fortify()`,...Did you accidentally pass `aes()` to the `data` argument?

我有这个数据

> 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()

但是我收到这个错误

Error: `data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class uneval
Did you accidentally pass `aes()` to the `data` argument?

我们需要将列名指定为不带引号的

library(dplyr)
library(ggplot2)
Social_Split %>%
   rownames_to_column('rn') %>%
   ggplot(aes(x = rn, y = V1)) + 
      geom_col()

-输出


或使用 base R

中的 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"))