ts.format: Format dates as POSIXct

View source: R/ts.format.R

ts.formatR Documentation

Format dates as POSIXct

Description

Converts dates from class character (format dd/mm/yyyy or other as specified) into class POSIXct and renames columns for use with other functions in the hydrostats package.

Usage

ts.format(x, format="%d/%m/%Y", cols=c(1,2))

Arguments

x

Dataframe including date and discharge data. Dates are assumed to be of class character (see format). The columns containing date and discharge data are required (defaults to renaming columns 1 and 2 to Date and Q respectively if no other columns are specified (see cols)).

format

Format of dates in existing data frame.

cols

A vector of column indices for the date and discharge data. Used to rename columns.

Details

Default assumes the date is of class character and in the first column, with discharge in the second column of the data frame. These columns can be specified if the defaults are not appropriate. The date and discharge columns are renamed to 'Date' and 'Q' respectively. For more flexibility in formatting dates/times see the lubridate package.

Value

A dataframe with the dates formatted as POSIXct and named columns Date and Q.

Author(s)

Nick Bond <n.bond@latrobe.edu.au>

Examples

data(Cooper)
Cooper<-ts.format(Cooper)

hydrostats documentation built on June 1, 2022, 9:06 a.m.