Skip to contents

Convert Column in Data Frame To Date

Usage

columnToDate(df, column, dbg = TRUE)

Arguments

df

data frame

column

name of column in x

dbg

if TRUE a debug message is shown

Value

df with column converted to class Date with

as.Date

Examples

df <- data.frame(id = 1:2, date = c("2018-10-23", "2018-10-23"))
str(df)
#> 'data.frame':	2 obs. of  2 variables:
#>  $ id  : int  1 2
#>  $ date: chr  "2018-10-23" "2018-10-23"

df <- columnToDate(df, "date")
#> Converting column 'date' to Date ... ok. (0.00 secs) 
str(df)
#> 'data.frame':	2 obs. of  2 variables:
#>  $ id  : int  1 2
#>  $ date: Date, format: "2018-10-23" "2018-10-23"