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, -113.111, -113.092, -112.987, -112.968), lat = c(33.6335, 33.5142, 33.3948, 33.6495, 33.5301), HGT = c(75.5519, 75.9582, 76.3957, 75.9269, 76.3019), RH = c(49.6484, 51.0234, 52.7734, 49.1484, 50.2734), TMP = c(305.495, 305.245, 305.057, 305.745, 305.495), UGRD = c(1.40155, 1.65155, 1.90155, 1.90155, 2.08905), VGRD = c(2.23264, 2.23264, 2.23264, 2.04514, 1.98264 )), .Names = c("forecast.date", "levels", "lon", "lat", "HGT", "RH", "TMP", "UGRD", "VGRD"), class = "data.frame", row.names = c(NA, -5L))
dta$Year <- as.integer( substr( dta$forecast.date, 1, 4 ) ) dta$Month <- as.integer( substr( dta$forecast.date, 6, 7 ) ) dta$Day <- as.integer( substr( dta$forecast.date, 9, 10 ) ) dta$Hour <- as.integer( substr( dta$forecast.date, 12, 13 ) ) dta On August 2, 2020 9:24:24 AM PDT, Philip <herd_...@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@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. -- Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@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.