[R] Error: Cannot Coerce POSIXt to POSIXct when building package
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Aug 8 16:27:42 CEST 2007
On Wed, 8 Aug 2007, Praveen Kanakamedala wrote:
> A newbie here - please forgive me if this is a basic question. We have an
> in house package built in R 2.2.1 (yes we're a little behind the times at
> our firm)and would like to rebuild it using R 2.5.1. However, when I try
> and build the package from source, I keep getting this error:
>
> Error in as(slotVal, slotClass, strict = FALSE) :
> no method or default for coercing "POSIXt" to "POSIXct"
> Error : unable to load R code in package 'Mango'
> Error: package/namespace load failed for 'Mango'
>
>
> I tried defining a new method "as.POSIXct" in the package to coerce POSIXt
> to POSIXct and then added the as.POSIXct method to the "NAMSPACE" file. The
> build still doesn't work (I get the same error message). Any idea what I am
> doing wrong? The coercion statement looks like this and works in R GUI:
How did you get this? There should be no objects of class 'POSIXt' alone,
and I get e.g.
> now <- Sys.time()
> as(now, "POSIXct")
Error in asMethod(object) : explicit coercion of old-style class (POSIXt,
POSIXct) is not defined
That can be fixed (see ?as), but you seem to have a malformed object in
one of your slots.
As often applies,
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> #from is a vector of dates in the format "%d-%b-%Y")
> from <- as.POSIXct(strptime(from, format = "%d%b%Y"), tz = "GMT")
>
> Here is my environment info:
>
> R version 2.5.1 (2007-06-27)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
> Kingdom.1252;LC_MONETARY=English_United
> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] "tcltk" "stats" "graphics" "grDevices" "utils" "datasets"
> "methods" "base"
>
> other attached packages:
> fSeries nnet mgcv fBasics fCalendar fEcofin spatial
> MASS
> "251.70" "7.2-34" "1.3-25" "251.70" "251.70" "251.70" "7.2-34" "
> 7.2-34"
> I would sincerely appreciate any help.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
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