给定一个有两列的csv文件,我想绘制条形图,以显示使用iPhone,mac,ipad和android发布的推文数量,按降序使用R。设备名称嵌入文本问题删除文本和绘制条形图。
data <- structure(list(Device = structure(c(1L, 1L, 2L,
3L, 4L, 5L), .Label = c("Twitter for iphone", "Twitter for android", "Twitter for mac", "Twitter for android", "Twitter for ipad",
"Twitter for android"), class = "factor"),Text = structure(c(5L,
3L, 6L, 4L, 2L, 1L), .Label = c("Matches is abandoned", "Policy changes in finance",
"Launches of new satellites", "Premium policy get activate by company abc",
"Technology makes trend",
"Weather forecasting by xyz"), class = "factor")), class = "data.frame", row.names = c(NA,
-6L))在使用给定的数据集绘制条形图时,使用R会出现错误。
发布于 2020-05-14 23:56:50
您的数据框包含两个具有原始信息的因子。条形图要求每个类别都有一个数字才能绘制。所以,你可以这样做。
barplot(table(data$Device))
barplot(table(data$Text))table计算因子水平的出现次数,并将其输入条形图。
https://stackoverflow.com/questions/61801629
复制相似问题