반응형
반응형
본문 바로가기

데이터 분석42

R 기초; 그래픽 - 그래프 패러미터 설정 R 기초; 그래픽 - 그래프 패러미터 설정 plot(faithful) plot(faithful, main="Old Faithful Geyser", sub="Yellowstone National Park", xlab="Eruptio time (minutes)", ylab="Waiting time (minutes)") ?par plot(faithful, las=0) plot(faithful, las=1) plot(faithful, las=2) plot(faithful, las=3) plot(faithful, bty="o") plot(faithful, bty="n") plot(faithful, bty="l") plot(faithful, bty="]") # 심볼과 선 plot(faithful, pch=3) pl.. 2021. 1. 23.
R 기초; 그래픽 - 그래프 생성 및 저장 R 기초; 그래픽 - 그래프 생성 및 저장 str(cars) plot(cars$speed, cars$dist) plot(cars) # 기니피그의 이빨 길이와 비타민C 보충제의원과의 관계를 기록한 실험 데이터 str(ToothGrowth) plot(ToothGrowth,$supp, ToothGrowth$len) str(iris) plot(iris[, 1:4]) str(nhtemp) plot(nhtemp) # 버클리 대학의 입학 허가 여부를 성별 6개의 학과 그리고 합격 불합격을 테이블 형식으로 데이터 str(UCBAdmissions) plot(UCBAdmissions) str(faithful) faithful.lm 2021. 1. 23.
R 기초; 고수준 및 저수준 그래픽 함수 R 기초; 고수준 및 저수준 그래픽 함수 - 완전한 하나의 그래프를 생성 - 그래프 창을 초기화하고, 축 눈금을 설정하고, 그래프 요소 (e.g. 제목, 축 이름)를 추가하고, 그 밖에 다양한 요소들을 결합하여 최종적으로 하나의 완성된 그래프를 생성 예시 - plot(): 제네릭 그래프 생성 (generic plotting) - boxplot(): 상자도표 (box plot) 생성 - his(): 히스토그램(histogram) 생성 - qqnorm(): Q-Q도표 (quantile-quantile plot) 생성 - curve(): 사용자 정의 함수로부터 그래프 생성 - 독자적으로 새로운 그래프를 생성할 수 없음 - 기존의 완성된 그래프에 부가적인 요소를 추가하는 역할 - 이미 생성된 그래프상에 점, 선.. 2021. 1. 23.
R 기초; 형태 변환2 - tidyr R 기초; 형태 변환2 - tidyr gather() spread() install.packages("tidyr") library(tidyr) # 뉴욕시 5개월 기간 동안 대기환경 정보 head(airquality) ?gather aq.long 2021. 1. 23.
R 기초; 형태 변환1 - reshape2 R 기초; 형태 변환1 - reshape2 melt() dcast() install.packages("reshape2") library(reshape2) smiths melt(data=smiths) melt(data=smiths, id.vars="subject") melt(data=smiths, measure.vars=c(2:5)) melt(data=smiths, measure.vars=c("time", "age", "weight", "height")) 2021. 1. 23.
R기초; 분할-적용-결합 - dplyr R기초; 분할-적용-결합 - dplyr arrange() filter() select() mutate() summarise() # 미국 뉴욕시 airquality 데이터 불러오기 head(airquality) Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36 118 8.0 72 5 2 3 12 149 12.6 74 5 3 install.packages("dplyr") library(dplyr) air 90) head(air) Ozone Solar.R Wind Temp Month Day 1 115 223 5.7 79 5 30 2 NA 259 10.9 93 6 11 3 NA 250 9.2 92 6 12 4 135 269 4.1 84 7 1 5 97 26.. 2021. 1. 17.
R 기초; 집단 요약 R 기초; 집단 요약 split() unstack() head(mtcars) mtcars 2021. 1. 16.
R 기초; 반복 적용 - Apply Family R 기초; 반복 적용 - Apply Family apply() lapply() sapply() mapply() ?apply x 2021. 1. 16.
R 기초; 서브셋 R 기초; 서브셋 # 자동차 데이터 description str(mtcars) # mtcars 데이터의 mpg 열 데이터 불러오기 mtcars$mpg mtcars[["mpg"]] mtcars[[1]] [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 [12] 16.4 17.3 15.2 10.4 10.4 14.7 32.4 30.4 33.9 21.5 15.5 [23] 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7 15.0 21.4 # 데이터 프레임 형식으로 1열 4열 데이터 불러오기 mtcars[c(1, 4)] mpg hp Mazda RX4 21.0 110 Mazda RX4 Wag 21.0 110 Datsun 710 22.8 9.. 2021. 1. 16.

반응형