Changing the xlim of numeric value causing error ggplot R

后端 未结 2 1708
粉色の甜心
粉色の甜心 2021-01-28 06:02

I have a grouped barplot produced using ggplot in R with the following code

ggplot(mTogether, aes(x = USuniquNegR, y = value, fill = variable)) +
geom_bar(stat =         


        
2条回答
  •  梦如初夏
    2021-01-28 06:35

    You need to remove the cbind from

    together<-data.frame(cbind(USperReasons,USperReasonsNY,USuniquNegR))
    

    because str(together) tells that all three columns are factors.

    With

    together <- data.frame(USperReasons, USperReasonsNY, USuniquNegR)
    

    the plot looks reasonable to me (without having to use ylim or xlim).

    So, the error was not within ggplot2 but in data preparation. Therefore, please, provide a full working example which can be copied, pasted and run when asking a question next time. Thank you.

提交回复
热议问题