3차원 시각화의 용도

다차원 시각화를 통해 복잡한 데이터의 분석과 설명이 가능하다.

3차원 시각화 방법

타 애플리케이션과 R의 연동 방법

구글 차트와의 연동을 통해 목적에 따른 다양한 종류의 차트를 웹 형태로 출력할 수 있다.

인터랙티브 방식은 사용자와 컴퓨터가 마치 대화를 하듯이 사용자가 클릭과 드래그를 통해 도표를 다룰 수 있게 해준다.

데이터 시각화

# 1) 패키지 불러오기
library(ggplot2)
library(corrplot)
library(treemap)
# 2) 만족도 점수시각화
satis<-data.frame(level=c("1. very unsatisfied","2. unsatisfied","3. satisfied","5. very satisfied"),score=c(-2,-1,1,2))
satis
ggplot(satis,aes(level,score,fill=score)) #높낮이를 정할 수 잇다.
+geom_bar(stat="identity")+scale_fill_gradient2() # 만족도에 따라 색깔을 그라데이션으로 나타내준다.
+ggtitle("Satisfaction Score")+theme_bw()

0859779a-cb82-4264-9917-e7983a38d1d6.png


# 3) 상관분석
# 한 변수가 높아질 때 다른 변수가 함께 높아지는지 혹은 낮아지는지 확인
corr<-cor(USArrests)
par(mfrow=c(1,3))
corrplot(corr,tl.pos="n",cl.pos="n",title="circular",mar=c(4,0,4,0))
corrplot(corr,method="shade",addshade="positive",tl.pos="n",cl.pos="n",title="shade",mar=c(4,0,4,0))
corrplot(corr,method="number",tl.pos="n",cl.pos="n",title="numerical",mar=c(4,0,4,0))

fc27716a-b4dc-4c43-b603-f9e86d4140e6.png

# 4) 달력 시각화
stock <- "MSFT"; start.date <- "2006-01-12"; end.date <- Sys.Date()
quote <- paste("<http://ichart.finance.yahoo.com/table.csv?s=>",stock, "&a=", substr(start.date,6,7),"&b=", substr(start.date, 9, 10),
               "&c=", substr(start.date, 1,4),"&d=", substr(end.date,6,7),"&e=", substr(end.date, 9, 10),"&f=", substr(end.date, 1,4),
               "&g=d&ignore=.csv", sep="")    
stock.data <- read.csv(quote, as.is=TRUE)
stock.data <- transform(stock.data,week = as.POSIXlt(Date)$yday %/% 7 + 1,wday = as.POSIXlt(Date)$wday,year = as.POSIXlt(Date)$year + 1900)
test<-stock.data[1:475,]
ggplot(test, aes(week, wday, fill = Adj.Close)) +geom_tile(colour = "white") +scale_fill_gradientn('MSFT \\n Adjusted Close',
colours = c("#D61818","#FFAE63","#FFFFBD","#B5E384"))+facet_wrap(~ year, ncol = 1)+theme_bw()

Screen Shot 2022-03-01 at 12.23.57 PM.png

# 5) 트리맵 시각화
data("GNI2014")
treemap(GNI2014,index=c("continent", "iso3"),vSize="population",vColor="GNI",type="value")

plot_zoom_png.png