weekYCol: weekYCol

Description Usage Arguments Value Examples

View source: R/weekYCol.R

Description

takes as input a date.frame object (dfName), a column name (dfColName), and the date format (dateFormat) of the column dfColName and inserts a new column containing the week of the year corresponding to the entries in the column dfColName. The location of the new column is dictated by endRep.

Usage

1
weekYCol(dfName, dfColName, dateFormat, endRep = "end")

Arguments

dfName

a string of class character indicating the name of the data.frame object to be used

dfColName

a string of class character indicating the name of the column to be handled. The entries in this column must be dates in the date format given by the parameter dateFormat

dateFormat

a character string indicating the date format of the column dfColName

endRep

a character string (default: "end") indicating whether to append the new columns at the end (endRep=="end") or replace the original columns with the respective new columns (endRep=="rep") or insert the new columns right after the respective columns (endRep=="after") in the data.frame object with name dfName.

Value

the modified data.frame object dfName which now contains a new column containing the week of the year corresponding to the entries in column dfColName of the original data frame. The entries in the new column are integers in the range [1,53]. If 1 January falls on either of Monday, Tuesday, Wednesday, Thursday then it belongs to week 1, otherwise week 53 of the last year. The first week of the year is the one that contains the first Thursday of the year.

Examples

1
2
3
4
weekYCol("rice","tillDate","%d.%m.%Y") 
weekYCol("rice","tillDate","%d.%m.%Y",F)
weekYCol("employees","date_of_birth","%Y-%m-%d")
weekYCol("employees","start_date","%Y-%m-%d",F)

lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.