How to plot one variable in ggplot?

前端 未结 5 1841
孤独总比滥情好
孤独总比滥情好 2020-12-23 16:48

I\'m searching but still can\'t find an answer to a quite simple question - how can we produce a simple dot plot of one variable with ggplot2 in R?

with plot<

5条回答
  •  渐次进展
    2020-12-23 17:14

    Actually, you are not plotting one variable, but two. X-variable is the order of your data. The answer to what you want based on your example is:

    library(ggplot2)
    ggplot(iris, aes(y = Sepal.Length, x = seq(1, length(iris$Sepal.Length)))) + geom_point()
    

    The answer to your question would be closer to this:

    ggplot(iris, aes(x = Sepal.Length)) + geom_dotplot()
    

提交回复
热议问题