#title R그래픽스 [[TableOfContents]] ==== 그룹별 plot ==== {{{ colour <- c("red", "black") plot(tmp$seq, tmp$up, col=c(colour[tmp$choice])) plot(tmp$seq, tmp$up, pch=tmp$choice) }}} ==== 표준화한 다음 라인차트 ==== {{{ lg <- c("선물", "최고동접") cl <- c("blue", "red") plot(scale(x$gift), type="l", col=cl[1]) lines(scale(x$mcu), col=cl[2]) legend(1.5, 2.4,lg, lty="solid", col=cl) }}} {{{ out3 <- survfit(Surv(time, status==1) ~ 요일, data=x1) plot(out3, col=c(1:7), lty=1:7) legend.txt <- c("일","월","화","수","목","금","토") legend("topright", legend=legend.txt, col=1:7, lty=1:7) summary(out3) }}} ==== mclust ==== {{{ install.packages("mclust") library("mclust") education <- read.csv("http://datasets.flowingdata.com/education.csv", header=T) head(education) > head(education) state reading math writing percent_graduates_sat pupil_staff_ratio dropout_rate 1 United States 501 515 493 46 7.9 4.4 2 Alabama 557 552 549 7 6.7 2.3 3 Alaska 520 516 492 46 7.9 7.3 4 Arizona 516 521 497 26 10.4 7.6 5 Arkansas 572 572 556 5 6.8 4.6 6 California 500 513 498 49 10.9 5.5 #2~7열까지를 사용해서 유클리드 거리를 구한다. ed.dis <- dist(education[,2:7]) #cmdscale -> 거리 행렬을 입력받아, 입력된 거리에 맞게 배치함. ed.mds <- cmdscale(ed.dis) x<- ed.mds[,1] y<- ed.mds[,2] plot(x,y) plot(x,y, type='n') text(x,y, label=education$state) ed.mclust <- Mclust(ed.mds) par(mfrow=c(2,2)) plot(ed.mclust, data=ed.mds) }}} ==== scotter plot & smooth line ==== {{{ require(graphics) with(cars, scatter.smooth(speed, dist)) ## or with dotted thick smoothed line results : with(cars, scatter.smooth(speed, dist, lpars = list(col = "red", lwd = 3, lty = 3))) }}} ==== treemap ==== 출처: 비주얼라이즈 디스, 에이콘 {{{ install.packages("portfolio") library("portfolio") posts <- read.csv("http://datasets.flowingdata.com/post-data.txt") head(posts) > head(posts) id views comments category 1 5019 148896 28 Artistic Visualization 2 1416 81374 26 Visualization 3 1416 81374 26 Featured 4 3485 80819 37 Featured 5 3485 80819 37 Mapping 6 3485 80819 37 Data Sources with(posts, map.market( id=id, area=views, group=category, color=comments, main="FlowsingData Map")) }}} attachment:R그래픽스/treemap.png?width=70%