我的数据如下:
service,rating_1,rating_2,rating_3,rating_4,rating_5 renew_patent,0,0,1,2,11 apply_benefit,21,20,121,828,1744 apply_employment_tribunal,0,0,0,0,0
我希望R为每行打印一个直方图,列为直方图的条形.
到目前为止我有这个:
require(lattice) data <- read.csv("test.csv", header = TRUE) colors = c('red', 'orange', 'yellow', 'blue', 'green') barchart(rating_1+rating_2+rating_3+rating_4+rating_5 ~ service, data=data, auto.key=list(space='right'), scales=list(x=list(rot=45)), ylab="Percentage of total", col=colors)
它正在工作,但它按字母顺序打印直方图,而不是按CSV文件中指定的顺序打印.
我怎样才能改变这一点,以便条形码在CSV文件中按顺序排列renew_patent
?