Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 정규성
- 워홀
- contrasts can be applied only to factors with 2 or more levels
- 예측
- VIF
- 회귀모형
- 엑셀
- 회귀분석
- post man
- disgusting
- KNNImputer
- 전처리
- 디시전트리
- 등분산성
- 분류
- 선형성
- 자기상관
- by oneself
- 다중공선성
- cook's distance
- 오류
- 등분산검정
- 기본가정
- 언어분석
- 기술통계분석
- sql
- 이변량 분석
- R
- 이상치
- 코딩테스트
Archives
- Today
- Total
excelsu의 공부 기록 블로그
R 에서 평균 비교 그래프 그리기(라이브러리 설치없이) 본문
보통 평균 비교를 위해 보통 밀도함수 그래프를 사용하지만
라이브러리없이 쉽고 빠르게 두 집단에 대해 분포를 확인하기 위해
히스토그램으로 작성하는 코드입니다.
#데이터 불러오기, header=TRUE로 첫째줄 컬럼명 지정
rawdata=read.csv(file=choose.files(), header=TRUE)
#x축 범위,구간 지정
x_range=seq(0, 45, by=3)
a=hist(rawdata$"컬럼명", breaks=x_range, plot=FALSE)
b=hist(rawdata$"컬럼명2", breaks=x_range, plot=FALSE)
#그래프 그리기
plot(a, col=abjustcolor("blue", alpha=0.5), ann=FALSE, axes=FALSE, ylim=c(0,y_max))
plot(b, col=abjustcolor("red", alpha=0.5), add=TRUE)
title(main="제목", xlab="x축이름", ylab="y축이름", cex.main=1.6)
#축 그리기
x_axis_tick=x_range
axis(side=1, at=x_axis_tick)
y_max=max(max(a$count), max(b$count)) #y축 길이
y_axis_tick=seq(0,y_max, by=3)
axis(side=2, at=y_axis_tick)
legend("topright", c("범례1","범례2"), fill=c(adjustcolor("blue",alpha=0.5),adjustcolor("red",alpha=0.5)))
#그래프 태두리
box("figure",col="gray")
'R' 카테고리의 다른 글
[오류] 회귀분석 coefficients : (7 not defined because of singularities) (0) | 2022.07.04 |
---|---|
[R오류]number of rows in use has changed remove missing values (0) | 2022.07.01 |
[회귀] plot 검정 (0) | 2022.07.01 |
[R오류] contrasts can be applied only to factors with 2 or more levels (0) | 2022.06.30 |
R 2개 집단 박스플롯 그리기 (0) | 2022.06.17 |