lazyDateCoding {Publish} | R Documentation |
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)
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. |
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.
Value
R-code one line for each variable.
Author(s)
Thomas Alexander Gerds
Examples
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")
[Package Publish version 2023.01.17 Index]