在geom_bar()中,将参数“ width =”设置为单位(例如“ mm”),而不设置数据分辨率的百分比(默认值)?
当我尝试使用此代码时:
df<-data.frame("x" = rep(c("a","b","c","d"), times = 3),
"y" = c(6,22,10,7,50,68,53,21,44,10,37,72),
"group" = rep(c("gp1","gp2","gp3"),each=4))
ggplot(data = df,aes(x = x, y = y, fill = group))+
geom_bar(aes(x = x, y = y, fill = group),
width = unit(5, "mm"),
stat = "identity")
它返回Error in Ops.unit(width, 2) : operator '/' not meaningful for units