Skip to content
Prev 385115 / 398503 Next

Parsing a Date

Hello,

And another solution, taking advantage of Rasmus' one:



simplify2array(parallel::mclapply(c(
 ? "%Y",
 ? "%m",
 ? "%d",
 ? "%H"), function(fmt, x) {
 ??? as.integer(format(as.POSIXct(x), format = fmt))
}, x = dta$forecast.date))
#???? [,1] [,2] [,3] [,4]
#[1,] 2020??? 8??? 1?? 12
#[2,] 2020??? 8??? 1?? 12
#[3,] 2020??? 8??? 1?? 12
#[4,] 2020??? 8??? 1?? 12
#[5,] 2020??? 8??? 1?? 12


The data set dta is Jeff's, it's in dput format.

Hope this helps,

Rui Barradas

?s 18:26 de 02/08/2020, Rasmus Liland escreveu: