R에서 막대그래프와 원형 그래프 그리는 방법21. 문제114 답
cafe.daum.net/oracleoracle
barplot( x ,main="년도별 치킨집 창업,폐업건수",
names.arg=create_cnt$X, col=c("blue","red"),
ylim=c(0,4000) , beside=T ,
legend =c("창업", "폐업") )
x <- rbind(create_cnt$치킨집, drop_cnt$치킨집)
23. 문제115 답
cafe.daum.net/oracleoracle
barplot( x ,main="년도별 카페 창업,폐업건수",
names.arg=create_cnt$X, col=c("blue","red"),
ylim=c(0,4000) , beside=T ,
legend =c("창업", "폐업") )
x <- rbind(create_cnt$커피음료, drop_cnt$커피음료)
35. 문제121 답
cafe.daum.net/oracleoracle
x2 <- create_cnt[ create_cnt$X =='2014', (2:8) ]
pie(t(x2), col=rainbow(7))
cnt_label <- round(x2/sum(x2) * 100,1)
cnt_label2 <- paste(colnames(cnt_label),t(cnt_label), '%')
pie(t(x2), col=rainbow(7), labels= cnt_label2)
37. 문제122 답
cafe.daum.net/oracleoracle
x2 <- create_cnt[ create_cnt$X =='2013', (2:8) ]
pie(t(x2), col=rainbow(7))
cnt_label <- round(x2/sum(x2) * 100,1)
cnt_label2 <- paste(colnames(cnt_label),t(cnt_label), '%')
pie(t(x2), col=rainbow(7), labels= cnt_label2,
main="2013년도 창업 현황" )
39. 문제123 답
cafe.daum.net/oracleoracle
show_pie <- function() {
graphics.off()
response <- readline(prompt ='년도를 입력하세요 ~' )
x2 <- create_cnt[ create_cnt$X == response , (2:8) ]
pie(t(x2), col=rainbow(7))
cnt_label <- round(x2/sum(x2) * 100,1)
cnt_label2 <- paste(colnames(cnt_label),t(cnt_label), '%')
pie(t(x2), col=rainbow(7), labels= cnt_label2,
main="2013년도 창업 현황" )
}
41. 문제124 답
cafe.daum.net/oracleoracle
show_pie <- function() {
graphics.off()
response <- readline(prompt ='년도를 입력하세요 ~' )
x2 <- create_cnt[ create_cnt$X == response , (2:8) ]
pie(t(x2), col=rainbow(7))
cnt_label <- round(x2/sum(x2) * 100,1)
cnt_label2 <- paste(colnames(cnt_label),t(cnt_label), '%')
pie(t(x2), col=rainbow(7), labels= cnt_label2,
main=paste(response, "년도 창업 현황" ) )
}
43. 문제125 답
cafe.daum.net/oracleoracle
show_bar <- function() {
graphics.off()
response <- readline(prompt ='업종을 입력하세요 ~' )
x <- rbind(create_cnt[,response] , drop_cnt[,response] )
barplot( x ,main="년도별 치킨집 창업,폐업건수",
names.arg=create_cnt$X, col=c("blue","red"),
ylim=c(0,4000) , beside=T ,
legend =c("창업", "폐업") )
}
45. 문제126 답
cafe.daum.net/oracleoracle
show_bar <- function() {
graphics.off()
response <- readline(prompt ='업종을 입력하세요 ~ ' )
x <- rbind(create_cnt[,response] , drop_cnt[,response] )
barplot( x ,
main= paste("년도별", response," 창업,폐업건수"),
names.arg=create_cnt$X, col=c("blue","red"),
ylim=c(0,4000) , beside=T ,
legend =c("창업", "폐업") )
}
49. 문제128 답
cafe.daum.net/oracleoracle
show_bar <- function() {
graphics.off()
response <- menu(c("x","미용실","양식집","일식집","치킨집"
,"커피음료","한식음식점","호프간이주점"),
title="Do you want this?")
x <- rbind(create_cnt[,response] , drop_cnt[,response] )
barplot( x ,
main= paste("년도별", response," 창업,폐업건수"),
names.arg=create_cnt$X, col=c("blue","red"),
ylim=c(0,4000) , beside=T ,
legend =c("창업", "폐업") )
}
52. 문제129 답
cafe.daum.net/oracleoracle
show_bar<-function(){
response<-menu(c("X","미용실","양식집","일식집",
"치킨집","커피음료","한식음식점","호프간이주점")
,title="Do you want this?")
graphics.off()
response<-colnames(create_cnt)[response]
x<-rbind(create_cnt[, response], drop_cnt[,response])
barplot(x, main=paste(response,"업종의 년도별 창업, 폐업건수")
,names.arg=create_cnt$X,col=c("blue","red"),
ylim=c(0,4000),beside=T,legend=c("창업","폐업"))
}
58. 문제132 답
cafe.daum.net/oracleoracle
emp <- read.csv("emp.csv",header=T)
x2 <- tapply(emp$sal,
list(emp$job,format(as.Date(emp$hiredate), '%Y')), sum)
x2[is.na(x2)] <- 0
x11()
barplot( x2, col = rainbow(5), beside =T )
legend('topright',legend=rownames(x2),fill=rainbow(5) )
61. 사랑하는 자여 네 영혼이 잘됨같이 네가 범사에 잘되고
강건하기를 내가 간구하노라
- 성경 요한삼서 1장 2절