On Fri, 10 Dec 2010, Jack Johnson wrote:

Hi,

I understand this should be an easy task but I am still struggling a bit to
read a .txt file with a date vector. My code is as below:


data<-read.table(file.choose(),header=TRUE,sep="\t",dec=",",colClasses=c("Date","numeric","numeric","numeric"))

But I am getting an error:

Error in charToDate(x) :
 character string is not in a standard unambiguous format


because my date vector is in a format below:

format="%d.%m.%Y"


But how can i define the date format for date vector in read.table
function....?

It is easiest to simply read the column as character, and convert later by as.Date(x, format="%d.%m.%Y")

You might want to consider using read.delim2 to get all the usual defaults for a tab-delimited file in a locale using comma as decimal separator.


Br,
Jack

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.


--
Brian D. Ripley,                  [email protected]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[email protected] 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.

Reply via email to