Maria
Maria

Reputation: 11

ggplot showing incorrect numbers

I have this data:

 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))

When I try to plot it, it shows all wrong. what am I doing wrong, please?

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

Upvotes: 0

Views: 569

Answers (1)

desc
desc

Reputation: 1210

If by "it shows all wrong" you mean that you're only getting y-values of 1, then it's likely due to not having a y-value in the original ggplot call.

Try this:

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

Which will generate this plot: enter image description here

Upvotes: 1

Related Questions