"R 특정컬럼이 결측치인 행 제거"의 두 판 사이의 차이

잔글 (Jmnote님이 R 특정컬럼이 결측치인 경우 행 제거 문서를 R 특정컬럼이 결측치인 행 제거 문서로 이동했습니다)
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
3번째 줄: 3번째 줄:
* 특정컬럼이 NA인 경우 그 행을 제거하는 방법
* 특정컬럼이 NA인 경우 그 행을 제거하는 방법


<source lang='r'>
<syntaxhighlight lang='r'>
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
Class  Name English Math
Class  Name English Math
23번째 줄: 23번째 줄:
## 3    B Carol      NA  80
## 3    B Carol      NA  80
## 4    B  Dave      60  90
## 4    B  Dave      60  90
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 15일 (일) 01:10 판

1 개요

R 특정컬럼의 결측치 행 제거
  • 특정컬럼이 NA인 경우 그 행을 제거하는 방법
df <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
Class  Name English Math
    A Alice      90   60
    A   Bob      80   NA
    B Carol      NA   80
    B  Dave      60   90
")
df
##   Class  Name English Math
## 1     A Alice      90   60
## 2     A   Bob      80   NA
## 3     B Carol      NA   80
## 4     B  Dave      60   90
df <- df[!is.na(df$Math),]
df
##   Class  Name English Math
## 1     A Alice      90   60
## 3     B Carol      NA   80
## 4     B  Dave      60   90

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}