I am trying to create a for loop which will find me the maximum year of deaths
I tried the following code:
result <- c()
years <- c("2020", "2021", "2022")
i <- 1
for (year in years){
result[i] <- data$age[which.max(data$year)]
i <- i + 1
}
However, this have me NULL as the result vector.
New contributor
user26863613 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.