[R] Help in running Stata dataset in R
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Aug 6 11:38:25 CEST 2008
What are use() and des()? Please note the footer of this message.
(Are you using package epicalc without telling us?)
I suspect that foreign::read.dta is being used. That has argument
'convert.dates', and you could try setting it to FALSE, as the message is
from as.Date.character() complaining about the date format.
It is likely that the difference is in the version of 'foreign' and not in
the version of R: the posting guide asked for the output of sessionInfo()
which would have told us which versions these were.
In short, try
library(foreign)
tmp <- read.dta("maltreat.dta", convert.dates=FALSE)
str(tmp)
tmp$dob
tmp$todaydate
and if the latter two are numbers, try converting them by e.g.
as.Date(tmp$dob, origin="1960-01-01")
It would help to make the dataset available for the developers to
investigate.
On Wed, 6 Aug 2008, Lazarus Mramba wrote:
> Dear All,
>
> I installed R 2.7.0 and tried to call a dataset i had ealier own called
> on R2.6.2 but i keep on getting an error:
> use("maltreat.dta")
>
> Error in fromchar(x) :
> character string is not in a standard unambiguous format
>
> Tried doing the same with R2.7.1 but i get the same error.
>
> However if i call the same on R 2.6.2, there is no error:
>
> use("maltreat.dta")
>> des()
>
> No. of observations = 670
> Variable Class Description
> 1 scrno integer
> 2 todaydate Date
> 3 ethnic character
> 4 othtribe character
> 5 dob Date
> 6 ageyrs integer
> 7 agemths integer
> 8 sex character
>
> I cannot figure out what the problem is.
>
> Please help me.
>
>
>
> Kind regards,
> Lazarus Mramba
> Junior Statistician
> P.O Box 986, 80108,
> Kilifi, Kenya
> Mobile No. +254721292370
> Tel: +254 41 522063
> Tel: +254 41 522390
> (office extension : 419)
>
> ______________________________________________
> 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.
>
--
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
More information about the R-help
mailing list