# BAR PLOT
l bar plot(막대그래프)
> barplot(emp$sal)
>> 아래의 그림을 R로 구현
tapply(사고선박수,list(substr(발생시기,6,7),관할해경서),sum) a <- tapply(사고선박수,list(substr(발생시기,6,7),관할해경서),sum) barplot(a,main="월별 해상사고", xlab="사고구역",ylab="사고횟수",axis.lty=2, legend=rownames(a),beside=T,col=rainbow(12))
|
> barplot(emp$sal, main="Salary Bar Cahrd")
|
> barplot(emp$sal, main="Salary Bar Chart", xlab="Name", ylab="Salary",names.arg=emp$ename)
|
> barplot(emp$sal, main="Salary Bar Chart", xlab="Name", ylab="Salary",names.arg=emp$ename,col=rainbow(15))
|
>> 직업, 직업별 토탈월급에 대한 막대 그래프를 그리시오
> x<-aggregate(sal~job,emp,sum) > barplot(x$sal,main="Salary Bar Chart", xlab="Name", ylab="Salary",names.arg=x$job,col=rainbow(5))
|
>> 부서번호별 직업별 인원수를 가로로 출력하시오
> tapply(empno,list(deptno,job),length) ANALYST CLERK MANAGER PRESIDENT SALESMAN 10 NA 1 1 1 NA 20 2 2 1 NA NA 30 NA 1 1 NA 4 70 NA 1 NA NA NA
> table(emp$deptno,emp$job) ANALYST CLERK MANAGER PRESIDENT SALESMAN 10 0 1 1 1 0 20 2 2 1 0 0 30 0 1 1 0 4 70 0 1 0 0 0
|
> x <- table(emp$deptno,emp$job) > barplot(x,ylab="인원수",col=c("red","yellow","green"),legend=rownames(x)) > barplot(x,ylab="인원수",col=c("red","yellow","green","blue"),legend=rownames(x))
|
> x <- merge(emp,dept) > attach(x) > b <- tapply(sal,loc,sum) > barplot(b, col=rainbow(4))
> barplot(b, col=rainbow(4),horiz=TRUE)
|
>> 부서위치별 직업별 토탈월급을 가로로 > x <- merge(emp,dept) > attach(x) > c <- tapply(sal,list(loc,job),sum) > barplot(c,ylab="인원수",col=c("red","yellow","green","blue"),legend=rownames(c),beside=T)
|
'빅데이터과정 > R' 카테고리의 다른 글
#50_140825_R_AUDIO GRAPH (0) | 2014.08.25 |
---|---|
#49_140822_R_LINE CHART (0) | 2014.08.22 |
#48_140821_R_SUBQUERY (0) | 2014.08.21 |
#48_140821_R_COUNT (0) | 2014.08.21 |
#48_140821_R_JOIN (0) | 2014.08.21 |