I have to create a function called vast that prints leap years between year1 and year2 as a vector.
So this is the code I have been using:
vast <- function(year1,year2){
year <- year1
for(year in year1:year2){
if(((year%%4==0)&(year%%100!= 0))|(year%%400==0))
vast <- print(year)
}
}
When I use vast(2000,2010), it should give (2000,2004,2008) as a vector that can be saved into x, but instead I get:
x <- vast(2000,2010)
[1] 2000
[1] 2004
[1] 2008
x
NULL
So the x is empty. I feel so stupid but I just can't figure it out.
Aucun commentaire:
Enregistrer un commentaire