add_Date_col: Create a Date column in the dataset

View source: R/add_Date_col.R

add_Date_colR Documentation

Create a Date column in the dataset

Description

Create a Date column in the dataset

Usage

add_Date_col(
  dataset,
  Date.colname = Date,
  group.by = FALSE,
  as.wday = FALSE,
  Datetime.colname = Datetime
)

Arguments

dataset

A light logger dataset. Expects a dataframe. If not imported by LightLogR, take care to choose a sensible variable for the Datetime.colname.

Date.colname

Name of the newly created column. Expects a symbol. The default(Date) works well with other functions in LightLogR. Will overwrite existing columns of identical name.

group.by

Logical whether the output should be (additionally) grouped by the new column

as.wday

Logical of whether the added column should calculate day of the week instead of date. If TRUE will create a factor with weekday abbreviations, where the week starts with Mon.

Datetime.colname

column name that contains the datetime. Defaults to "Datetime" which is automatically correct for data imported with LightLogR. Expects a symbol. Needs to be part of the dataset. Must be of type POSIXct.

Value

a data.frame object identical to dataset but with the added column of Date data

Examples

sample.data.environment %>% add_Date_col()
#days of the week
sample.data.environment %>% 
  add_Date_col(as.wday = TRUE, group.by = TRUE) |> 
  summarize_numeric(remove = c("Datetime"))


LightLogR documentation built on June 10, 2025, 5:12 p.m.