How to plot histogram in R?

ε祈祈猫儿з 提交于 2019-12-13 10:02:32

问题


I am using R and I would like to plot a histogram where x-axis is the number of vehicles and y-axis is the time interval. Something like:


回答1:


I guess you need a barplot:

x <- data.frame(n_vehicles = c(10, 20, 30, 40),
                time_interval = c(2, 5, 4, 9))
barplot(height = x$time_interval,
        names.arg = x$n_vehicles)

Or alternatively:

plot(x = x$n_vehicles,
     y = x$time_interval,
     type = "h")

The "h" stands for "histogram".



来源:https://stackoverflow.com/questions/38480183/how-to-plot-histogram-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!