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,] 20
On 2020-08-02 09:24 -0700, Philip wrote:
| Below is some Weather Service data. I
| would like to parse the forecast date
| field into four different columns:
| Year, Month, Day, Hour
Dear Philip,
I'm largely re-iterating Eric and Jeff's
excellent solutions:
> dat <- structure(list(f
Learn to post plain text and use dput to include data:
dta <- structure(list(forecast.date = c("2020-08-01 12:00:00", "2020-08-01
12:00:00", "2020-08-01 12:00:00", "2020-08-01 12:00:00", "2020-08-01 12:00:00"
), levels = c("1000 mb", "1000 mb", "1000 mb", "1000 mb", "1000 mb" ), lon =
c(-113.13
If the forecast.date column is of type character you can use lubridate to
do this:
> library(lubridate)
> a <- "2020-08-01 12:00:00"
> year(a)
# [1] 2020
> month(a)
# [1] 8
etc
On Sun, Aug 2, 2020 at 7:24 PM Philip wrote:
> Below is some Weather Service data. I would like to parse the foreca
Below is some Weather Service data. I would like to parse the forecast date
field into four different columns:
Year
Month
Day
Hour
I would like to drop the final four zeros. Any suggestions?
forecast.date levels lon lat HGT RH
5 matches
Mail list logo