我正在熟悉tidyverse。能够使用默认的barchart()生成条形图,但我遇到了这个问题。所有对象的长度都是相等的,我不确定我在aoe()中犯了什么错误。提前谢谢你。
### Sample data
df <- data.frame(a = c(sample(500:2000,50)),
b = c(sample(500:2000,50)),
c = c(sample(500:2000,50)),
d = c(sample(500:2000,50)),
e = c(sample(500:2000,50)),
f = c(sample(500:2000,50)),
g = c(sample(500:2000,50)),
h = c(sample(500:2000,50)),
i = c(sample(500:2000,50)),
j = c(sample(500:2000,50)),
k = c(sample(500:2000,50)),
l = c(sample(500:2000,50)),
m = c(sample(500:2000,50)),
n = c(sample(500:2000,50)))
### Assign values to objects
totals <- apply(df, 2, sum)
names <- c(colnames(df))
### Create bar chart
ggplot(df, aes(x = names, y = totals)) + geom_bar(stat = "identity")
Ge19WdSt指的是什么?
library(ggplot2)
ggplot(cbind.data.frame(names,totals),aes(x = names, y = totals)) + geom_bar(stat = "identity")