0

I am trying to create a time series plot in R based on data from a .csv file converted from an Excel file. But I'm having a few issues when reading it into R.

Firstly, when I input the date into Excel I'm using the format of m/d/yyyy H:M:S (for example: 6/5/2017 20:15:00). But when I hit return, after entering each date, Excel formats it to short date. This displays the the date as m/d/yyyy and doesn't display the time in the columns. So when I import the .csv into R I get the following:

>head(Data)
Date        Value
6/4/2017    180
6/4/2017    300
6/4/2017    120
6/4/2017    340
6/5/2017    300

I have tried reformatting the Date column by following this other stack overflow post... but I just end up with a column of NA's for Date.

I have also tried converting the dates to numeric in Excel, by following this R-Blogges guide and importing them into R that way... but I still end up with only m/d/yyyy in R and no times!

As my dataset is clustered around only a few days, the time variable is the important factor when producing the time series. Any suggestions as to how I'd fix this?

Alanis
  • 27
  • 2
  • 4
  • 1
    Have you set the format for the column in Excel? There is a format that covers m/d/yyyy H:M:S – G5W Jun 05 '17 at 17:18
  • @G5W Thanks, I just found the format that does m/d/yyyy H:M in excel... the 'seconds' variable isn't actually recorded in my data, so this formatting should work. Thanks for your help, I didn't know there were more formatting types than the ones displayed by default in Excel. – Alanis Jun 05 '17 at 17:30
  • As I understand time was not in the csv, so it's not an R question, – moodymudskipper Jun 06 '17 at 13:03

0 Answers0