티스토리 뷰

R

(macOS)[R] plot : scatter plot, histogram, box plot

jinozpersona 2022. 3. 29. 13:01

INTRO

1. scatter plot : 산점도 그래프, 산점도 행렬

2. histogram : 히스토그램, 막대그래프(bar chart)

3. box plot : 상자그림

 

 

1. scatter plot

scatter plot

 x, y 변수 값을 평면에 점을 찍어 한눈에 볼 수 있도록 표현

test_plot_scatter.R
## scatter plot
height = sample(x=150:180, size=20)
weight = sample(x=50:90, size=20)
plot(height, weight)

출력결과

 

 

scatter plot:matrix

 다변수에 대해 상호간 산점도를 한눈에 볼 수 있도록 확장된 산점도 행렬

 "main=" : 최상단 제목

 "pch=" : 점 모양

 "bg=" : 점 색상

test_plot_scatter_matrix.R
## scatter plot:matrix
pairs(iris[1:4], main="Anderson's Iris Data -- 3 species", 
      pch=21, bg=c('red','green3','blue')[unclass(iris$Species)])

출력결과

 

2. histogram

탐색적 자료 분석에서 자료 분포를 손쉽게 확인하는 방법

test_plot_histogram.R
## histogram
statscore = sample(c(30:100), size=50, replace=T)
#print(statscore)
hist(statscore, prob=T)

 

출력결과

3. box plot

최댓값, 최소값, 중앙값, 사분편차를 사용하여 자료의 분포를 나타내는 방법

test_plot_box.R
## boxplot
statscore = sample(c(30:100), size=50, replace=T)
#print(statscore)
boxplot(statscore)

출력결과

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함