如何在R中绘制直方图? [英] How to plot histogram in R?

查看:373
本文介绍了如何在R中绘制直方图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R,我想绘制一个直方图,其中x-axis是车辆数量,y-axis是时间间隔. 像这样:

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:

推荐答案

我想您需要一个barplot:

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)

或者:

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

"h"代表直方图".

这篇关于如何在R中绘制直方图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆