Re: [R] Parsing a Date

2020-08-02 Thread Rui Barradas
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

Re: [R] Parsing a Date

2020-08-02 Thread Rasmus Liland
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

Re: [R] Parsing a Date

2020-08-02 Thread Jeff Newmiller
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

Re: [R] Parsing a Date

2020-08-02 Thread Eric Berger
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

[R] Parsing a Date

2020-08-02 Thread Philip
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