ggplot显示不正确的数字

时间:2020-02-05 17:06:42

标签: r ggplot2

我有以下数据:

 structure(list(Sexo = structure(c(1L, 2L, 1L, 2L), .Label = c("Female", 
"Male"), class = "factor"), Status = structure(c(1L, 1L, 2L, 
2L), .Label = c("Active", "Terminated"), class = "factor"), Freq = c(1367L, 
7030L, 394L, 940L)), class = "data.frame", row.names = c(NA, 
-4L))

当我尝试绘制它时,它显示所有错误。请问我在做什么错?

razao1%>%
  ggplot(aes(x=as.factor(Status), fill = factor(Status)))+
  geom_bar(position = "fill")+ 
  facet_wrap(~Sexo)    

1 个答案:

答案 0 :(得分:1)

如果“显示所有错误”表示您的y值仅为1,则可能是由于原始ggplot调用中没有y值。

尝试一下:

razao1%>%
  ggplot(aes(x=Status, y = Freq, fill = Status))+
  geom_bar(stat="identity")+ 
  facet_wrap(~Sexo)

将生成以下图: enter image description here