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])

+ Recent posts