lazyDateCoding: Efficient coding of date variables
Description
This function eases the process of generating date variables.
All variables in a data.frame which match a regular expression
are included
Usage
lazyDateCoding(data, format, pattern, varnames, testlength = 10)
Value
R-code one line for each variable.
Arguments
data
Data frame in which to search for date variables.
format
passed to as.Date
pattern
match date variables
varnames
variable names
testlength
how many rows of data should be evaluated to guess the format.
Author
Thomas Alexander Gerds
Details
The code needs to be copy-and-pasted from the R-output
buffer into the R-code buffer. This can be customized
for the really efficiently working people, e.g., in emacs.
d <- data.frame(x0="190101",x1=c("12/8/2019"),x2="12-8-2019",x3="20190812",stringsAsFactors=FALSE)
lazyDateCoding(d,pattern="x")
lazyDateCoding(d,pattern="3")