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: tojulian

Function Description: tojulian

Accepts any character representation of a date and a description of the format. The submitted dates can be a vector or a matrix. See strptime for details about the format. Returns a julian date, the number of days since 1 Jan 1960; a julian is an integer and can be graphed or operated as such, though it displays as a date.

Function Arguments:

ArgumentDefault Value
x
dateform'%m/%d/%Y'

Sample Usage:

tojulian(c('23Oct2010','29Mar1956'),'%d%b%Y')


Function Source:

tojulian=function(x,dateform='%m/%d/%Y')
{
x=strptime(x,format=dateform)

year=x$year+1900

month=x$mon+1
day=x$mday
return(mdy.date(month=month,day=day,year=year))
}