问题
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