I have a variable say a which has data as Count | Value 2 | Apple 5 | Ball 6 | Cat 10 | Dog 我想绘制一个柱状图,将数值放在x轴上,计数放在y轴上。不知道该怎么做。
我们可以使用 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))