Make histogram from data table in R [duplicate]

十年热恋 提交于 2020-04-07 05:51:20

问题


I have a variable say a which has data as

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

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


回答1:


We can use barplot

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

data

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))


来源:https://stackoverflow.com/questions/36759077/make-histogram-from-data-table-in-r

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