ggplot对一元运算符的无效参数

时间:2018-04-24 13:00:02

标签: r ggplot2 pie-chart

运行ggplot饼图时,我收到以下错误消息...任何想法可能是什么问题?

代码是:

ggplot(pie_unrated, aes(x = "FEBRUARY IBG UNRATED Book COMPOSITION", y = prop, 
fill = ProductDetails)) + geom_bar(width = 1, 
stat = "identity", color = "white") 
+ coord_polar(theta = "y", start = 0) + ggpubr::fill_palette("jco") 
+theme_void()

我的错误消息:

 Error in +coord_polar(theta = "y", start = 0) : 
    invalid argument to unary operator

>

 dput(head(pie_unrated)
structure(list(RatingStatus = c("UNRATED", "UNRATED", "UNRATED", 
"UNRATED", "UNRATED", "UNRATED"), ProductDetails = structure(c(1L, 
2L, 6L, 7L, 9L, 10L), .Label = c("ACB", "Bonds", "Cash and Short Term", 
"Deposit with Banks", "LBD", "LC", "LG", "loan", "Loan", "OD", 
"Treasury Bonds"), class = "factor"), counts = c(10L, 1L, 21L, 
102L, 758L, 126L), prop = c(1, 0.1, 2.1, 10, 74.5, 12.4), lab.ybos = c(0.5, 
1.05, 2.15, 8.2, 50.45, 93.9)), .Names = c("RatingStatus", "ProductDetails", 
"counts", "prop", "lab.ybos"), row.names = c(NA, -6L), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), vars = "RatingStatus", drop = TRUE, indices = list(
    0:5), group_sizes = 6L, biggest_group_size = 6L, labels = structure(list(
    RatingStatus = "UNRATED"), row.names = c(NA, -1L), class = "data.frame", vars = "RatingStatus", drop = TRUE, .Names = "RatingStatus"))

1 个答案:

答案 0 :(得分:0)

library(ggpubr)

ggplot(pie_unrated, 
     aes(x = "FEBRUARY IBG UNRATED Book COMPOSITION", y = prop, fill = ProductDetails)) + 
geom_bar(width = 1,stat = "identity", color = "white") + 
coord_polar(theta = "y", start = 0) + ggpubr::fill_palette("jco") + theme_void()
相关问题