In a normal one off script way I have a data.table with headings:
Date | Time | Value
Which then has the Date
and Time
pasted together to be parsed as POSIX later on.
The problem is in trying to parametrise (I think that's the right word) the process into a function, I can't guarantee that Date
will always be explicitly "Date". It could easily be date
, DATE
, rdate
(for some reason), or really anything.
Right now my function produces:
Date | Time | Value | DateTime
.. but as I've mentioned, DateTime
could easily be rDateTime
. Time
and Value
are set elsewhere however, and will not change.
EDIT Currently the function captures the actual character string from the function inputs.
function(hhDT, colDate = "rdate")
The question is:
In setcolorder
, where the column headers are supplied as characters in the c()
function like so:
setcolorder(fooDT, c("col1", "col2", "col3",....))
What is the 'correct' way to supply the argument to the c()
when it is partly known and partly user defined, and captured in the character object colDate
?
i.e.
setcolorder(fooDT, c(
colDate
, "Time", result of paste(colDate, "Time"), "Value"))
Where colDate
is a character string referred to with argument colDate, and result of ... is the result of that pseudo code i.e. rDateTime
or dateTime
or randomstringTime
.