【发布时间】:2021-11-06 01:51:47
【问题描述】:
我正在尝试使用 coord_polar 使用 ggplot2 绘制饼图。但是我收到如下错误消息。
unique.default(x, nmax = nmax) 中的错误: unique() 仅适用于向量
以下是我使用的代码。有人可以告知导致此错误的原因
freqtable <- table(worms$Vegetation)
df <- as.data.frame.table(freqtable)
colnames(df)<-c("Vegetation","Frequency")
pie<- ggplot(df, aes(x = "", fill = factor(class))) +
geom_bar(width = 1) + theme(axis.line = element_blank(),plot.title = element_text(hjust=0.5)) +
labs(fill="class",x=NULL, y=NULL, title="Pie Chart of Vegetation", caption="Source: Worms")
pie+coord_polar(theta = "y", start=0)
感谢和问候, 拉希姆
【问题讨论】:
标签: r ggplot2 polar-coordinates