I'm creating a function that returns leap years. However, my code returns the results in the form of logical vector. How can I get the results in numeric vector. For example, for the below code the result should be "c(2000,2004,2008)"
"ans<- function(year1, year2)
{return(((c(year1:year2) %% 4 == 0) & (c(year1:year2) %% 100 != 0)) | (c(year1:year2) %% 400 == 0)); return(c(year1:year2))}"
ans(2000,2010)
TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE