R2-10 第三期ggplot2画柱状图

superhong 2017-11-21 21:28:53 阅读: 916

rm(list = ls())

work.dir <- "F:/R Learning/exercise/R2-03/"

setwd(work.dir)

library(ggplot2)

library(reshape2)

library(ggthemes)

getwd()  #check working directory

data3_1 <- read.csv("R2-3.1.csv",sep=',', header=TRUE)

data3_2 <- read.csv("R2_3_2.csv",sep=',', header=TRUE)


head(data3_1)

data3_1 <- melt(data3_1,id.vars="Products",variable.name = "Time",value.name="Index")

library(ggplot2)

library(reshape2)

library(ggthemes)

ggplot() +scale_fill_wsj("rgby")+geom_bar(data=data3_1,aes(x=Time,y=Index,fill=Products),stat="identity",position="dodge")+theme_economist()+ggtitle("R2-10")

1.png

ggplot(data3_2,aes(社区,fill=态度))+geom_bar(position='stack')+coord_flip()+ylab("频数")+ggtitle('R2-10')

2.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号