Re: [R] Error in fromchar(as.character(x)) : character string is not in a standard unambiguous format

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Fri, 11 Apr 2008 13:18:09 +0200

Hi

r-help-bounces_at_r-project.org napsal dne 11.04.2008 12:47:57:

> Brian,
>
>
> Thanks for your reply. The data I have was downloaded from a
> government database so it now seems that the problem is how to
> convert all the records in the format '1-Apr-08' to the format
2008-04-11.

There is no need to convert it externally. Your Order.Made.Date is not time but factors. You need to to transform them to time/date format e.g. by

time.data<-strptime(your data, format = .....)

see as.Date for details.

Then you can use them in your construction without any problem.

Regards
Petr

>
> I can ask the person working on the new version of this database
> whether they will use this standard, it certainly isn't in common use.
>
> Your explanation did make the help files, which I typically struggle
> with, clearer.
>
>
> Bob
>
>
> At 07:03 PM 11/04/2008, you wrote:
> >You need to give the format -- might mean 2008-04-01 or 2001-04-08,
> >and R refuses to guess.
> >
> >Please *do* read the help file (e.g. as.Date) before posting: the
> >international standard format is , and Australia has adopted that
standard.
> >
> >On Fri, 11 Apr 2008, Bob Green wrote:
> >
> >>Hello,
> >>
> >>I was hoping for advice regarding resolving the above error.
> >
> >Telling R what you intend is the usual way to resolve user errors
> >caused by ambiguous input.
> >
> >>
> >>I have a csv file that contains the following variable:
> >>
> >> $ Order.Made.Date : Factor w/ 299 levels
> >>"1-Apr-08","1-Aug-05",..: 278 285 91 286 159 132 108 261 282 147 ...
> >>
> >>
> >>I want to calculate a variable named F.length, which is today's date
> >>minus the values contained in the variable: April$Order.Made.Date)
> >>I tried altering the date format but continued to receive the same
error.
> >>
> >> > F.length <- difftime ("11/04/2008", April$Order.Made.Date)
> >> > Error in fromchar(as.character(x)) : character string is not in
> >>a standard unambiguous format
> >>
> >> > Order.date <- as.Date (April$Order.Made.Date)
> >> > Error in fromchar(x) : character string is not in a standard
> >>unambiguous format
> >> > Order.date <- 'as.POSIXlt' (April$Order.Made.Date)
> >>Error in fromchar(as.character(x)) : character string is not in a
> >>standard unambiguous format
> >>
> >>Any suggestions are appreciated,
> >>
> >>Bob
> >
> >
> >--
> >Brian D. Ripley, ripley_at_stats.ox.ac.uk
> >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
>
> ______________________________________________
> 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.



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. Received on Fri 11 Apr 2008 - 11:22:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Apr 2008 - 11:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive