R ifelse()

Jmnote bot (토론 | 기여)님의 2021년 4월 14일 (수) 02:00 판 (봇: 자동으로 텍스트 교체 (-<source +<syntaxhighlight , -</source> +</syntaxhighlight>))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

R ifelse()
  • "Conditional Element Selection"
a <- c(3, 1, 4, 1, 5, 9)
ifelse(a %% 2 == 0, "even", "odd")
df <- read.table( header=TRUE, sep=",", stringsAsFactors=FALSE, text="
id,score
1,40
2,60
3,45
4,50
5,25
")
df
df$result <- ifelse(df$score >= 50, "pass", "fail")
df

2 같이 보기[ | ]

3 참고[ | ]

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