Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, David Winsemius wrote: 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"

Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 1:21 PM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, David Winsemius wrote: > >> I took the code that I offered earlier and replaced allyears with wy2018: > >> date timeelev myDate myTime >> 1 2017-10-01 00:00 290.298 2017-10-01 2017-10-01 00

Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, David Winsemius wrote: I took the code that I offered earlier and replaced allyears with wy2018: date timeelev 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

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 12:33 PM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, Rich Shepard wrote: > >> I have the date and elev columns converted from factors to date and >> numeric, respectively, but still have not learned how to convert the time. > > With this dataframe structure, > > str(

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 10:02 AM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, Rich Shepard wrote: > >> Since then I reformatted the file to two fields: date-time and elevation. >> If anyone wants a copy send me a message off the list and I'll respond with >> the modified file attached. > > Th

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: I have the date and elev columns converted from factors to date and numeric, respectively, but still have not learned how to convert the time. With this dataframe structure, str(wy2018) 'data.frame': 12592 obs. of 3 variables: $ date: Date, forma

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: Since then I reformatted the file to two fields: date-time and elevation. If anyone wants a copy send me a message off the list and I'll respond with the modified file attached. This is a mistake. The file needs commas separating each field. I have

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: I put a zipped data file at this URL: Since then I reformatted the file to two fields: date-time and elevation. If anyone wants a copy send me a message off the list a

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Wed, 18 Jul 2018, Rich Shepard wrote: If you would suggest how many would be an acceptably large number I'll be happy to put that on a 'cloud' sharing site and provide the URL to it. I put a zipped data file at this URL:

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
On Wed, 18 Jul 2018, David Winsemius wrote: It's not so much as factors but rather in a form that paste() will coerce to character so you cna get the automatic format David, Now I understand. Maybe you need to add a format string. It might force some of your pasted date+time values to NA

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread David Winsemius
> On Jul 18, 2018, at 4:07 PM, Rich Shepard wrote: > > On Wed, 18 Jul 2018, David Winsemius wrote: > >> I would not destroy the possibility of using the original values: > > David, > > What are the benefits of keeping date and time as factors? > >>> allyears$myDate <- as.Date(as.character(

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
On Wed, 18 Jul 2018, David Winsemius wrote: I would not destroy the possibility of using the original values: David, What are the benefits of keeping date and time as factors? allyears$myDate <- as.Date(as.character(allyears$date)) allyears$myTime <- as.POSIXct(paste(allyears$date, allyea

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread David Winsemius
> On Jul 18, 2018, at 2:50 PM, Rich Shepard wrote: > > A set of data files have this format: > > date,time,elev > 1988-10-01,00:30,87.6849 > 1988-10-01,01:00,87.6849 > 1988-10-01,01:30,87.6849 > 1988-10-01,02:00,87.6879 > 1988-10-01,02:30,87.6879 > 1988-10-01,03:00,87.691 > 1988-10-01,03:30,8

[R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
A set of data files have this format: date,time,elev 1988-10-01,00:30,87.6849 1988-10-01,01:00,87.6849 1988-10-01,01:30,87.6849 1988-10-01,02:00,87.6879 1988-10-01,02:30,87.6879 1988-10-01,03:00,87.691 1988-10-01,03:30,87.694 Importing it with this command: allyears <- read.table('allyears.da