Parsing a Date
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 <herd_dog at cox.net> wrote:
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 TMP UGRD VGRD
1 2020-08-01 12:00:00 1000 mb -113.130 33.6335 75.5519 49.6484 305.495
1.40155 2.23264
2 2020-08-01 12:00:00 1000 mb -113.111 33.5142 75.9582 51.0234 305.245
1.65155 2.23264
3 2020-08-01 12:00:00 1000 mb -113.092 33.3948 76.3957 52.7734 305.057
1.90155 2.23264
4 2020-08-01 12:00:00 1000 mb -112.987 33.6495 75.9269 49.1484 305.745
1.90155 2.04514
5 2020-08-01 12:00:00 1000 mb -112.968 33.5301 76.3019 50.2734 305.495
2.08905 1.98264
Philip Heinrich
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.