[R] Problem in handling Date format

David Winsemius dwinsemius at comcast.net
Wed Apr 23 07:52:25 CEST 2014


On Apr 22, 2014, at 10:10 PM, Ashis Deb wrote:

> Hi all  ,
> 
> I have this  data  like ,  ashdata
> 
>             YHOO.Open  YHOO.High YHOO.Low YHOO.Close YHOO.Volume YHOO.Adjusted
> 2007-01-03     25.85     26.26    25.26      25.61    26352700         25.61
> 2007-01-04     25.64     26.92    25.52      26.85    32512200         26.85
> 2007-01-05     26.70     27.87    26.66      27.74    64264600         27.74
> 2007-01-08     27.70     28.04    27.43      27.92    25713700         27.92
> 2007-01-09     28.00     28.05    27.41      27.58    25621500         27.58
> 2007-01-10     27.48     28.92    27.44      28.70    40240000         28.70
> 
> 
>> I had put it in a csv in my desktop using
> write.csv(ashdata,"D:/ashdata1.csv")
> 
> Then I tried to access the csv using read.csv("D:/ashdata1.csv")
> 
> but when I accessed the data , the "date" format changed to numeric
> expression like
> 
> 10 ,20 ,30 ,
> 
> Can anybody suggest a simple way to handle Dates in R , could not find any
> function .
> 

The initial display looks like an xts or zoo data-object. The dates would be row.names and the interior entries part of the coredata matrix. `write.csv` might not be the proper vehicle for saving such an object.
It sounds like you got the dates read in as character variables which unfortunately means they were probably automatically converted to factors, given the stringsAsFactors is an option that is TRUE by default.

-- 
David.


> Sorry for such a basic Questions.
> 
> 
> Thanks You
> 
> ASHIS
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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




More information about the R-help mailing list