Error : arguments imply differing number of rows
Error : arguments imply differing number of rows
row 수 안맞음
> df <- data.frame( A=c(1,2,3,4), B=c(1,2,3,4,5,6))
Error in data.frame(A = c(1, 2, 3, 4), B = c(1, 2, 3, 4, 5, 6)) : arguments imply differing number of rows: 4, 6
자동으로 맞춰서 row수 맞춤
> df <- data.frame( A=c(1,2,3), B=c(1,2,3,4,5,6)) > df <- data.frame( A=c(1,2), B=c(1,2,3,4,5,6))
NA
a <- c(1,2,NA)
[1] 1 2 NA
NA 갯수 확인
sum(length(which(is.na(a))))
[1] 1
NA제거
a <- a[!is.na(a)]
[1] 1 2
a <- as.factor(c("A", "B", NA))
[1] A B <NA> Levels: A B
a <- a[na.omit(a)]
[1] A B Levels: A B