Topic: Utilities
Topic Description:
Basic R utilities used in many packages and functions, such as date and string manipulations, statistical distributions, geometry of lines and distances. The R package date is required for the two data functions.
File: utilities/utilities.r
| View File Source | Download File | No help file available |
Function: is.leap
Function Description: is.leap
Return a logical indicating which elements of a vector are leap years.Function Arguments:
| Argument | Default Value |
|---|---|
| yr | |
| start | 1904 |
| end | 2096 |
Function Source:
is.leap=function(yr,start=1904,end=2096)
{
leapyears=seq(start,end,by=4)
matchleap=match(yr,leapyears)
leap=(!is.na(matchleap))
nonleap=seq(100,3000,by=100)
matchnonleap=match(yr,nonleap)
leap[!is.na(matchnonleap)]=FALSE
leapyears=seq(400,3000,by=400)
matchleap=match(yr,leapyears)
leap[!is.na(matchleap)]=TRUE
return(leap)
}
{
leapyears=seq(start,end,by=4)
matchleap=match(yr,leapyears)
leap=(!is.na(matchleap))
nonleap=seq(100,3000,by=100)
matchnonleap=match(yr,nonleap)
leap[!is.na(matchnonleap)]=FALSE
leapyears=seq(400,3000,by=400)
matchleap=match(yr,leapyears)
leap[!is.na(matchleap)]=TRUE
return(leap)
}