> On Jul 19, 2018, at 1:21 PM, Rich Shepard <rshep...@appl-ecosys.com> wrote: > > On Thu, 19 Jul 2018, David Winsemius wrote: > >> I took the code that I offered earlier and replaced allyears with wy2018: > >> date time elev myDate myTime >> 1 2017-10-01 00:00 290.298 2017-10-01 2017-10-01 00:00:00 >> 2 2017-10-01 00:30 290.301 2017-10-01 2017-10-01 00:30:00 >> 3 2017-10-01 01:00 290.304 2017-10-01 2017-10-01 01:00:00 >> 4 2017-10-01 01:30 290.295 2017-10-01 2017-10-01 01:30:00 >> 5 2017-10-01 02:00 290.292 2017-10-01 2017-10-01 02:00:00 >> 6 2017-10-01 02:30 290.289 2017-10-01 2017-10-01 02:30:00 >> 7 2017-10-01 03:00 290.289 2017-10-01 2017-10-01 03:00:00 >> 8 2017-10-01 03:30 290.289 2017-10-01 2017-10-01 03:30:00 >> 9 2017-10-01 04:00 290.280 2017-10-01 2017-10-01 04:00:00 >> >>> str(wy2018) >> 'data.frame': 9 obs. of 5 variables: >> $ date : Factor w/ 1 level "2017-10-01": 1 1 1 1 1 1 1 1 1 >> $ time : Factor w/ 9 levels "00:00","00:30",..: 1 2 3 4 5 6 7 8 9 >> $ elev : num 290 290 290 290 290 ... >> $ myDate: Date, format: "2017-10-01" "2017-10-01" ... >> $ myTime: POSIXct, format: "2017-10-01 00:00:00" "2017-10-01 00:30:00" ... > > David, > > Thank you. I see the results in the dataframe structure although I still > don't understand all the reasons. The 'myTime' column confirms what I > thought: that there is no separate time data type. I'll use what you taught > me an move on with the analyses.
You can use format to only display the time portion of a datetime object. format( Sys.time(), "%H:%M") [1] "13:57" You can append the current date to a "time-only" character value and as.POSIXct will do that for you: as.POSIXct("00:00", format="%H:%M") [1] "2018-07-19 PDT" > as.POSIXct(c("00:00", "00:01"), format="%H:%M") [1] "2018-07-19 00:00:00 PDT" "2018-07-19 00:01:00 PDT" There is a difftime-class in base R And the lubridate package defines a duration class. It's not a package I use, and I cannot tell off the top of my head what it thinks the difference might be between a "time-span" and a "duration". Best of luck. > > Best regards, > > Rich > > ______________________________________________ > 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. David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law ______________________________________________ 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.