(1)建一个测试的DATASET:> a<-seq(2,10,2) > b<-seq(10,100,20) > c<-as.matrix(a,b) > c [,1] [1,] 2 [2,] 4 [3,] 6 [4,] 8 [5,] 10 > c<-data.frame(a,b) > c<-as.matrix(c) > c a b [1,] 2 10 [2,] 4 30 [3,] 6 50 [4,] 8 70 [5,] 10 90
(2)根据测试DATASET,来画图
>barplot(c,main="Test",xlab="Product",ylab="xiaohao",col=c("red","blue","yellow","black","green"),legend=rownames(c))> barplot(c,main="Test",xlab="Product",ylab="xiaohao",col=c("red","blue","yellow","black","green"),legend=rownames(c),beside=TRUE)
#R#barplot
最新推荐文章于 2024-04-12 09:50:18 发布