[R] Conversion from string to date type

Gabor Grothendieck ggrothendieck at gmail.com
Fri Mar 23 23:28:33 CET 2007


Read the help desk article in R-News 4/1 and see

?as.Date
?strptime (for setting the as.Date format= argument)

Also, you might be interested in the zoo package

library(zoo)
?read.zoo
vignette("zoo")
vignette("zoo-quickref")


On 3/23/07, Andreas Tille <tillea at rki.de> wrote:
> Hi,
>
> I'm on my very first steps to R and so I hope that I do
> not ask a really stupid questions but I did not found it
> via R-Search, in the FAQ or Google (BTW, the name "R" is
> not a really good seekiong criterion ;-) ).
>
> I have a data file containing a table that containes
> dates and values like
>
> date\t value1\t value2, ...
> 01.03.2007\t 17\t 42\t ...
> 02.03.2007\t 2\t 3\t ...
> 03.03.2007\t 47\t 11\t ...
> ...
>
> I was perfectly able to read this file via
>
> mydata <- read.csv(file='mydata.dat', sep = '\t', quote='', fill=TRUE,header=TRUE )
>
> but the date vector is a vector of strings instead of date values.
> I want to convert these strings into date values to be able
> to make graphs where date is the x-axis and value? the y-axis.
>
> I would be really happy if someone could enlighten me how to
> do this conversion (and a hint how to do a graph as PNG) would
> be an extra bonus which would shorten my further reading of the
> docs).
>
> Kind regards and thanks for your help
>
>           Andreas.
>
> --
> http://fam-tille.de
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list