score <- c(67, 84, 69, 50, 95, 60, 82, 71, 88, 84)
which(score==69)
which(score>=85)
max(score)
which.max(score)
min(score)
which.min(score)
# max() 함수와 which.max() 함수의 차이점
# max() 함수는 해당하는 값을 출력하지만,
# which.max() 함수는 해당하는 값의 인덱스를 출력한다.
# 성적이 60 이하인 값들은 61점으로 상향조정
score[which(score<=60)] <- 61
# 성적이 80 이상인 값들만 추출
score[which(score>=80)]
#성적이 제일 좋은 학생들의 이름 추출하기
score <- c(60, 40, 95, 80)
names(score) <- c('John', 'Jane', 'Tom', 'David')
score
idx <- which.max(score)
names(scores[idx])
'Data Science > R' 카테고리의 다른 글
[R 시각화] 히스토그램 그리기 (0) | 2021.10.04 |
---|---|
[R 시각화] 막대그래프 그리기 (0) | 2021.10.04 |
[R 문법] 사용자 정의 함수에서 여러 개의 값을 반환하는 경우 (0) | 2021.10.04 |
[R 문법] apply( ) 함수 (0) | 2021.10.04 |
[R 문법] ifelse 문 (0) | 2021.10.04 |