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
- by oneself
- 등분산검정
- post man
- 등분산성
- 정규성
- 분류
- VIF
- cook's distance
- 자기상관
- 언어분석
- 예측
- 전처리
- contrasts can be applied only to factors with 2 or more levels
- 워홀
- 오류
- 이변량 분석
- sql
- 엑셀
- 선형성
- 회귀분석
- 회귀모형
- 기본가정
- 기술통계분석
- KNNImputer
- 디시전트리
- 이상치
- 다중공선성
- R
- 코딩테스트
- disgusting
Archives
- Today
- Total
excelsu의 공부 기록 블로그
[R오류] contrasts can be applied only to factors with 2 or more levels 본문
회귀분석을 진행하다가
lm(rawdata$qwe~., data=rawdata)
를 실행했는데
contrasts can be applied only to factors with 2 or more levels
오류가 떴다.
원인은 여러가지가 있는데
한컬럼의 데이터가 전부 같을때 발생한다.
전부 같은데이터인지 확인하기 위해서는
values_count <- sapply(lapply(data, unique), length) # Identify variables with 1 value
values_count
lm(y ~ ., data[ , values_count > 1])
으로 확인해 보면 된다.
그래도 해결이 안된다면 na값이 있을때 발생하는 오류이기때문에 na값을 채워주거나 행을 삭제하고 실행하면 된다..
참고 : https://statisticsglobe.com/r-error-contrasts-applied-to-factors-with-more-levels
R Error: contrasts can be applied only to factors with 2 or more levels
How to solve the error message "contrasts can be applied only to factors with 2 or more levels" in R - Programming examples & code in RStudio
statisticsglobe.com
'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 2개 집단 박스플롯 그리기 (0) | 2022.06.17 |
R 에서 평균 비교 그래프 그리기(라이브러리 설치없이) (0) | 2022.06.17 |