- 전체
- Sample DB
- database modeling
- [표준 SQL] Standard SQL
- G-SQL
- 10-Min
- ORACLE
- MS SQLserver
- MySQL
- SQLite
- postgreSQL
- 데이터아키텍처전문가 - 국가공인자격
- 데이터 분석 전문가 [ADP]
- [국가공인] SQL 개발자/전문가
- NoSQL
- hadoop
- hadoop eco system
- big data (빅데이터)
- stat(통계) R 언어
- XML DB & XQuery
- spark
- DataBase Tool
- 데이터분석 & 데이터사이언스
- Engineer Quality Management
- [기계학습] machine learning
- 데이터 수집 및 전처리
- 국가기술자격 빅데이터분석기사
- 암호화폐 (비트코인, cryptocurrency, bitcoin)
stat(통계) R 언어 R 실습 학습 2017-10-28 레슨4: 데이터 시각화
2017.10.28 20:10
R 실습 학습 2017-10-28 레슨4: 데이터 시각화
# R 실습 학습 2017-10-28 레슨4: 데이터 시각화
#### 레슨4 : 데이터 시각화 ####
#### 과제 ####
# 1. "Cars93.txt"파일은 1993년 미국에서 판매된 자동차에 대한 자료이다.
# 파일을 읽어 "data"에 저장하시오.
# 2. 위에서 생성한 "data"자료 중 제조국가 (Origin)가 "USA"이고 화물용량
# (Luggage.room)의 값이 있는 자료만 선택하여 "data.sub"에 저장하시오.
# 3.숫자형 벡터를 입력받아 자료의 평균과 중앙값을 반환하는 함수 mm을
# 작성하시오. 예시로 data.sub 데이터 프레임의 Length열을 사용하여 확인해보시오.
# 4. "data.sub"의 "Price", "Length", "Width", "Weight" 4개의 열에 함수 mm을
# 적용하여 각 열에 대한 평균값과 중앙값을 "result"행렬에 저장하시오.
# 5. "reuslt"결과를 "Cars93_mm.txt" 파일에 저장하시오.
# (구분자는 Tab, 행 이름음 없음)
#### question 1 : solv ####
data <- read.table("...경로../Cars93.txt",
header = T, sep = "\t")
str(data)
dim(data)
t(names(data))
class(t(colnames(data)))
head(data)
#### question 2 : solv ####
data.sub <- sebset(data,
Origin="USA" & !is.na(Luggage.room),
c("Make", "Price", "Length", "Width", "Weight"))
dim(data.sub)
names(data.sub)
head(data.sub)
#### question 3 : solv ####
mm <- function(x) {
round(c(mean=mean(x), median = median(x)), 3)
}
mm
mm(data.sub$Length)
#### question 4 solv : apply ####
result <- apply(data.sub[-1], 2, mm)
result <- apply(data.sub[-1],mm)
class(result)
result
#### question 5 : solv ####
write.table(result, "경로명 ... 파일명",
sep = "\t", quote = F, row.names=F, na="")
#### color and graph ####
# googling : "R color cheatsheet"
#### R Colors ####
colors()
color <- c("#FF0000", "#FFFF00", "#00FF00", "#0000FF", "#FF00FF")
pie(rep(1,5), col=color, labels = color)
par(new=T)
pie(rep(1,1), col = "white", radius= 0.5, labels = "")
pie(rep(1,12), col = rainbow(12), border = "black",
clockwise = TRUE, labels = "")
par(new=T)
pie(rep(1,1), col="white", radius = 0.3, border = "white", labels = "")
# colors that grDevice package provide
n <- 11
barplot(rep(1,n), col = rainbow(n, alpha = 1), axes = F, main="rainbow colors")
barplot(rep(1,n), col = rainbow(n, alpha = 0.3), axes = T, main="rainbow colors")
barplot(rep(1,n), col = heat.colors(n, alpha = 1), axes = F, main="rainbow colors")
barplot(rep(1,n), col = terrain.colors(n, alpha = 1), axes = F, main="rainbow colors")
barplot(rep(1,n), col = topo.colors(n, alpha = 1), axes = F, main="rainbow colors")
barplot(rep(1,n), col = cm.colors(n, alpha = 1), axes = F, main="rainbow colors")
n <- 11
pie(rep(1,n), col = rainbow(n), main="rainbow colors")
pie(rep(1,n), col = heat.colors(n), main="heat colors")
pie(rep(1,n), col = terrain.colors(n), main="terrian colors")
pie(rep(1,n), col = topo.colors(n), main="topo colors")
pie(rep(1,n), col = cm.colors(n), main="cyan-magenta colors")
pie(rep(1,n), col = rainbow(n), main="rainbow colors")
pie(rep(1,n), col = rainbow(n), main="rainbow colors")
pie(rep(1,n), col = rainbow(n), main="rainbow colors")
pie(rep(1,n), col = rainbow(n), main="rainbow colors")
# HEX code
rainbow(8, alpha=1)
cm.colors(12, alpha = 0.3)
cm.colors(12)
# RColorBrewer package
install.packages("RColorBrewer")
library(RColorBrewer)
# sequential
display.brewer.all(type = "seq")
barplot(rep(1,7), col = brewer.pal(7, "Reds"), axes = F, main="Brewer Reds")
barplot(rep(1,7), col = brewer.pal(7, "Greens"), axes = F, main="Brewer Greens")
barplot(rep(1,7), col = rev(brewer.pal(7, "Greens")), axes = F, main="Brewer Reds")
# diverging
display.brewer.all(type = "div")
# qualitative
display.brewer.all(type = "qual")
#### Stem-and-Leof Plots ####
BabeRuth <- data.frame(year=1920:1934,
homerun = c(54,59,35,41,46,25,47,60,54,46,49,46,41,34,22))
BabeRuth
?stem
stem(BabeRuth$homerun)
stem(BabeRuth$homerun, scale = 2)
#### Histogram ####
hist(BabeRuth$homerun)
hist(BabeRuth$homerun, xlim = c(0, max(BabeRuth$homerun)* 1.2))
hist(BabeRuth$homerun, xlim = c(0, max(BabeRuth$homerun)* 1.2), breaks = 10)
hist(BabeRuth$homerun, xlim = c(0, max(BabeRuth$homerun)* 1.2),
main = "Home runs of Babe Ruth", xlab = "Number of Home runs", ylab = "Frequency",
col = c(rep("lightblue", 2), rep("royalblue", 2), rep("navyblue",4)))
#### Bar graph ####
bloodtype <- c(rep("A", 25), rep("B", 50), rep("O", 20), rep("AB", 15))
table(bloodtype)
sort.bloodtype <- sort(table(bloodtype), decreasing = T)
sort.bloodtype
par(mfrow = c(1,2))
slices <- c("red", "blue", "yellow", "green")
pie(sort.bloodtype, col = slices, radius = 1, main="pie chart")
barplot(sort.bloodtype, col = slices, main="bar graph of blood type")
dev.off()
# pie chart
?"grDevices"
require(grDevices)
parties <- c("first", "second", "third", "fourth")
seats <- c(122,123,38,6)
pie.vote <- round(prop.table(seats),4)
pie.vote
seats/sum(seats)
prop.table(seats)
table(seats)
names(pie.vote) <- paste(parties, seats, "명", sep="")
par(mfrow = c(1,2))
cols -> c("red", "midnightblue", "green", "magenta", "yellow")
par(family = "AppleGothic")
pie()
#### Big mac Index: 환율 : 빅맥버거 ####
bm1 <- read.csv("빅맥지수 데이터 csv")
summary(bm1)
str(bm1)
head(bm1)
names(bm1[1:7])
bm1 <- na.omit(bm1[1:7])
sort(bm1$dollar_price, decreasing = T)
library(ggplot2)
ggplot(bm1, aes(x=factor(Country), y=dollar_valuation)) +
geom_bar(stats = "identity")
ggplot(bm1, aes(x = dollar_valuation)) +
geom_point(size = 3) +
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.x = element_line(color="#C3AEFF", linetype = "dashed")) +
labs(title = "Big Mac Index of Jan 2016") +
xlab("Dollar Price($)") +
ylab("Country")
ggplot(bm1, aes(x=reorder(Country, dollar_price), y=dollar_price)) +
geom_point(size = 3) +
theme_bw()
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 공지 | 오라클 기본 샘플 데이터베이스 | 졸리운_곰 | 2014.01.02 | 86134 |
| 공지 | [SQL컨셉] 서적 "SQL컨셉"의 샘플 데이타 베이스 SAMPLE DATABASE of ORACLE | 가을의 곰을... | 2013.02.10 | 78636 |
| 공지 | [G_SQL] Sample Database | 가을의 곰을... | 2012.05.20 | 95362 |

