1 개요[ | ]
- R ifelse()
- "Conditional Element Selection"
R
Copy
a <- c(3, 1, 4, 1, 5, 9)
ifelse(a %% 2 == 0, "even", "odd")
Loading
R
Reload
Copy
df <- read.table( header=TRUE, sep=",", stringsAsFactors=FALSE, text="
id,score
1,40
2,60
3,45
4,50
5,25
")
df
Loading
Copy
df$result <- ifelse(df$score >= 50, "pass", "fail")
df
Loading
2 같이 보기[ | ]
3 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.