경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

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()
 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
공지 오라클 기본 샘플 데이터베이스 졸리운_곰 2014.01.02 86126
공지 [SQL컨셉] 서적 "SQL컨셉"의 샘플 데이타 베이스 SAMPLE DATABASE of ORACLE 가을의 곰을... 2013.02.10 78629
공지 [G_SQL] Sample Database 가을의 곰을... 2012.05.20 95347
18 TensorFlow Lite 101 - MoblieNet 맛보기 file 졸리운_곰 2018.05.30 1089
17 Apache MXNet에서 사전 트레이닝된 모델을 사용해 보세요. 졸리운_곰 2018.05.30 988
16 MXNet을 활용한 이미지 분류 앱 개발하기 file 졸리운_곰 2018.05.30 1424
15 세상에 있는 (거의) 모든 머신러닝 문제 공략법 file 졸리운_곰 2018.05.30 1119
14 sklearn 내부의 pickle lib 를 통해 모델을 저장하고 다시 로드하여 재사용할 수 있다. 졸리운_곰 2018.05.30 1636
13 텐서플로우 기반 딥러닝 훈련 모델 파일 저장, 로딩 및 재활용 file 졸리운_곰 2018.05.30 1765
12 TensorFlow 모델을 저장하고 불러오기 (save and restore) 졸리운_곰 2018.05.30 1637
11 텐서플로우(TensorFlow)를 이용해서 글자 생성(Text Generation) 해보기 – Recurrent Neural Networks(RNNs) 예제 – Char-RNN file 졸리운_곰 2018.05.13 1122
10 외장형 그래픽카드로 우분투에서 텐서플로우 사용 How to setup an eGPU on Ubuntu for TensorFlow file 졸리운_곰 2018.05.09 1426
9 Keras and NLTK 케라스를 이용한 NLTK 자연어처리 졸리운_곰 2018.05.08 1600
8 Windows7에서 "처음 심층 학습 프로그램」을 사경 보면 (1-2) 제 1 장 후반 file 졸리운_곰 2018.05.08 1138
7 CSLAIER CSLAIER에 의한 LSTM file 졸리운_곰 2018.05.08 1661
6 Tensorboard 사용하기 1 file 졸리운_곰 2018.05.08 1410
5 텐서보드 사용법 file 졸리운_곰 2018.05.08 1407
4 Ubuntu 18.04 Settings for TensorFlow 설치 file 졸리운_곰 2018.05.08 1181
3 딥러닝용 서버 설치기 file 졸리운_곰 2018.05.07 1391
2 Installing Tensorflow GPU on Ubuntu 18.04 LTS file 졸리운_곰 2018.05.06 1215
1 TensorFlow Lite 101 - MoblieNet 맛보기 file 졸리운_곰 2018.04.07 1272
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED