# How can i loop this code in R till 2009 for example?

I have a data from 2000 to 2009, i have to calculate the average of mintemperature, maxtemperature, relative humidity and present it as data frame. Can I loop this code until 2009?

``````setwd('D:/Kuliah/Semester 3/Meteorologi Komputasi')

rm(list=ls())
dir(pattern = 'xls')
excel_sheets('Bengkulu.xlsx')

suhuMin1 = round(sapply(d.iklim(1:366, 3), mean, na.rm = TRUE), 2)
suhuMax1 = round(sapply(d.iklim(1:366, 4), mean, na.rm = TRUE), 2)
suhuAvg1 = round(sapply(d.iklim(1:366, 5), mean, na.rm = TRUE), 2)
kelembapan1 = round(sapply(d.iklim(1:366, 6), mean, na.rm = TRUE), 2)
curah_hujan1 = sapply(d.iklim(1:366, 7), sum, na.rm = TRUE)
tahun_2000 = c(suhuMin1, suhuMax1, suhuAvg1, kelembapan1, curah_hujan1)

suhuMin2 = round(sapply(d.iklim(367:731, 3), mean, na.rm = TRUE), 2)
suhuMax2 = round(sapply(d.iklim(367:731, 4), mean, na.rm = TRUE), 2)
suhuAvg2 = round(sapply(d.iklim(367:731, 5), mean, na.rm = TRUE), 2)
kelembapan2 = round(sapply(d.iklim(367:731, 6), mean, na.rm = TRUE), 2)
curah_hujan2 = sapply(d.iklim(367:731, 7), sum, na.rm = TRUE)
tahun_2001 = c(suhuMin2, suhuMax2, suhuAvg2, kelembapan2, curah_hujan2)
``````