从R中的数据表制作直方图 [英] Make histogram from data table in R

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

问题描述

我有一个变量say a,其数据为

I have a variable say a which has data as

Count |  Value
2 | Apple
5 | Ball
6 | Cat
10 | Dog

我想构建一个直方图,这样,我在x轴上具有值,而在y轴上具有计数.不知道该怎么办

I want to construct a histogram such that, I have the values in x-axis and count in y axis. Dont know how to do

推荐答案

我们可以使用barplot

barplot(setNames(df1$Count, df1$Value))

数据

df1 <- structure(list(Count = c(2, 5, 6, 10), Value = c("Apple", "Ball",  
"Cat", "Dog")), .Names = c("Count", "Value"), class = "data.frame",
 row.names = c(NA, -4L))

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

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