我想使用ggplot,我的数据就是这样
x <- c(TRUE,FALSE,TRUE,FALSE) #Logical
y <- c(0,1,0) #Numeric
dat <- data.frame(x,y)
我想创建一个显示百分比的堆叠式条形图...这似乎应该是一个简单的问题,但不知何故我搞砸了,找不到直接的答案。
我已经尝试过了
ggplot(data = dat,aes(x = x,y = y,fill = y))+geom_bar(position = 'fill',stat = 'identity')
ggplot(data = dat,y = factor(y),stat = 'identity')
第二个看起来更近,但是轴将所有内容压缩为0?