I am learning R and trying to import some stock market data. The sample data is
{"2017-12-07 13:07:00": {"1. open": "169.7800", "2. high": "169.9100", "3. low": "169.7800", "4. close": "169.8500", "5. volume": "20659"}, "2017-12-07 13:06:00": {"1. open": "169.7920", "2. high": "169.8300", "3. low": "169.7400", "4. close": "169.7700", "5. volume": "17485"}, "2017-12-07 13:05:00": {"1. open": "169.8600", "2. high": "169.8600", "3. low": "169.7350", "4. close": "169.7924", "5. volume": "19789"}, "2017-12-07 13:04:00": {"1. open": "169.8000", "2. high": "169.8800", "3. low": "169.7600", "4. close": "169.8600", "5. volume": "25589"}, "2017-12-07 13:03:00": {"1. open": "169.7800", "2. high": "169.8100", "3. low": "169.7100", "4. close": "169.8100", "5. volume": "19679"}, "2017-12-07 13:02:00": {"1. open": "169.9400", "2. high": "169.9400", "3. low": "169.7700", "4. close": "169.7799", "5. volume": "46347"}, "2017-12-07 13:01:00": {"1. open": "169.9540", "2. high": "170.0200", "3. low": "169.9400", "4. close": "169.9500", "5. volume": "66847"}, "2017-12-07 13:00:00": {"1. open": "169.9400", "2. high": "169.9439", "3. low": "169.9100", "4. close": "169.9400", "5. volume": "8546"}}
I am trying to load it in a way I can have timestamp as well as values. I have as of now, tried this
tmp <- fromJSON(readLines(i))
data <- data.frame(matrix(unlist(tmp),ncol=5,byrow = TRUE))
This code is letting me have the values but I am unable to retain the timestamp. Please guide me on how can I have the values as well as timestamps.