similar to: Suggestion for exception handling: More informative error message for "no applicable method..." (S3)

Displaying 20 results from an estimated 10000 matches similar to: "Suggestion for exception handling: More informative error message for "no applicable method..." (S3)"

2009 Mar 18
1
Why S4 methods of S3 'base' generics are not used in 'base' functions ?
Dear list, It seems that S4 methods defined for an S3 'base' generic are not used in 'base' functions. This can be problematic when 'base' functions start with something like 'as.matrix'. ### START R code setClass("classA", contains = "matrix", representation(realData = "numeric")) setMethod("as.matrix",
2002 Feb 28
1
Bug in julian() (PR#1332)
Full_Name: Michael Jacob Version: 1.4.1 OS: Windows 2000 SP2 Submission from: (NULL) (195.27.237.226) Hi, there seems to be a bug in julian(): > Sys.getlocale() [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=English_United States.1252" > julian(Sys.time()) Error in fromchar(x) : character string is not in a
2007 Dec 06
1
S3 and S4 clash
Hello: How can I work around the conflict between the S3 and S4 illustrated in the example below? I'm developing a package that requires a function in 'stats4', but when 'stats4' is attached, it breaks my AIC function. I could give my AIC function another name so it no longer uses the generic dispatch, but I wonder if there is another way. Thanks,
2009 Nov 11
1
Clarification on generic functions and methods
I have constructed the following functions and need a little clarification: ### function to fit the model parameters jml.fit <- function(dat, con = 1e-3, bias=FALSE, ...){ do stuff ... } ### default function which calls jml.fit jml.default <- function(dat, con = 1e-3, bias=FALSE, ...){ result <- jml.fit(dat, con = 1e-3, bias) result$call <- match.call() class(result) <-
2010 Sep 13
1
Problem with all.equal and POSIXt.
I'm getting an error when applying all.equal() to objects of class POSIXt. E.g. x <- strptime(rep("2007-02-12",10),format="%Y-%m-%d") all.equal(x,x) Error in target[[i]] : subscript out of bounds The object seems to have to be of double-digit length to trigger the error. E.g. all.equal(x[1:9],x[1:9]) returns TRUE. I did a cursory search of the r-help pages and
2010 Jun 13
1
S4 classes and S3 generic functions
A general goal for the next version of R is to make S4 and S3 play better together. As mentioned in a previous thread, one limitation has been that S3 generic functions, specifically the UseMethod() call, did not make use of S4 inheritance when dispatching on general S4 objects. This has been fixed in a version committed today (updated to rev 52267). The code change is not large, but it
2003 Oct 02
1
"[[<-","[[" default?
Hi! I have implemented class specific behaviour of "[[<-.myclass"<-function(). How it is posible to call the "[[.default" on an object of myclass? Eryk Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics Ihnestrasse 73 14195 Berlin 'v' tel: 0049-30-84131285 / \ mail: wolski@molgen.mpg.de ---W-W----
2011 Aug 26
1
R.oo data members / inheritance
If someone is able, can you tell me if there is a better way to do this? More specifically, do I have to rewrite all of the data members stuff and extend stuff of parent class in the child class? See below. Thanks in advance! Example 1: setConstructorS3("ClassA", function(A,x) { if(missing(A))A=15; if(missing(x))x=NA; extend(Object(), "ClassA", .size = A, .x=x
2007 Aug 08
2
Error: Cannot Coerce POSIXt to POSIXct when building package
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"
2008 Nov 05
1
Methods dispatch and inheritance R.oo
Hi to all members, i have a question about class inheritance and methods using R.oo package: I have the following code and it doesn't work, guess i'm doing smth wrong and there is nothing in the help. library(R.oo) setConstructorS3("ClassA", function(A=15) { extend(Object(), "ClassA", .size = A ); }) setMethodS3("print", "ClassA",
2009 Oct 15
2
forwarded: bug (?) in cut.POSIXt with "breaks"=integer
From: Vitalie S. <vitosmail <at> rambler.ru> Subject: Bug in cut.POSIXt Newsgroups: gmane.comp.lang.r.general Date: 2009-10-15 15:47:48 GMT (1 hour and 29 minutes ago) Hello Everyone, Before reporting decided to post here first: tt <- structure(c(1254238817, 1254238859, 1254238969, 1254239080), class = c("POSIXt",
2010 Feb 01
1
Error with cut.POSIXt and daylight savings time switchover dates
The following code: cut(as.POSIXct("2009-11-01 04:00:00", tz="America/Los_Angeles"), "1 day") gives the error: Error in seq.int(0, to - from, by) : 'to' must be finite This is related to November 1st, 2009 being the switchover date from daylight savings time to standard time in the America/Los_Angeles time zone. In particular, in cut.POSIXt, the starting
2009 Jul 07
2
[LLVMdev] How to add an include file
Hi Eli, Let's say I have a file ClassA.h, that pairs with a file ClassA.cpp to product a library libClassA.a. ClassA.h contains the single declaration. class A {...}; I want to transform it to: #include "ClassB.h" class A : public class B {...}; ClassB.h is the header file for a library libClassB.a built from ClassB.cpp and ClassB.h. I can clearly link libClassB with libClassA.
2012 Mar 19
1
diff(time) vs. difftime?
I just encountered another RTFM problem: With diff(as.POSIXct(...), ...) I was unable to control the units of the results. Examples: > (d.d <- diff(as.POSIXct(c('2012-12-12', '2012-12-13')))) Time difference of 1 days > (d.h <- diff(as.POSIXct(c('2012-12-12 08:00', '2012-12-12 09:00')))) Time difference of 1 hours > (d.m <-
2009 Jul 07
0
[LLVMdev] How to add an include file
On Tue, Jul 7, 2009 at 1:42 AM, David Minor<dahvid.minor at gmail.com> wrote: > Hi Eli, > Let's say I have a file ClassA.h, that pairs with a file ClassA.cpp > to product a library libClassA.a. > ClassA.h contains the single declaration. > > class A {...}; > > I want to transform it to: > > #include "ClassB.h" > > class A : public class B
2013 Jan 28
1
Suggestions for 'diff.default'
I have suggestions for function 'diff.default' in R. Suggestion 1: If the input is matrix, always return matrix, even if empty. What happens in R 2.15.2: > rbind(1:2) # matrix [,1] [,2] [1,] 1 2 > diff(rbind(1:2)) # not matrix integer(0) > sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United
2018 Jun 16
2
Comparar variables fecha formato POSIXct
Tengo dos dataframe que corresponden a los valores horarios de los contaminantes y el otro a los valores horarios de las variables meteorológicas para el mismo periodo de tiempo. La variable temporal date en ambos dataframe tiene el formato dmy_hms. Los dataframe tienen diferente número de filas. dataframe contaminantes contiene 175247 filas y el dataframe meteorología 175321. Quiero saber
2007 May 07
2
getting informative error messages
Certain errors seem to generate messages that are less informative than most -- they just tell you which function an error happened in, but don't indicate which line or expression the error occurred in. Here's a toy example: > f <- function(x) {a <- 1; y <- x[list(1:3)]; b <- 2; return(y)} > options(error=NULL) > f(1:3) Error in f(1:3) : invalid subscript type
2016 Apr 18
3
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Scenario: An S3 method is declared for an S4 base class but called for an instance of a derived class. Steps to reproduce: > Rscript -e "test <- function(x) UseMethod('test', x); test.Matrix <- function(x) 'Hi'; MatrixDispatchTest::test(Matrix::Matrix())" Error in UseMethod("test", x) : no applicable method for 'test' applied to an
2006 Mar 15
1
Additional arguments in S3 method produces a warning
Hello, I just notice this: > x <- c(1:4,0:5, 4, 11) > library(pastecs) Loading required package: boot > tp <- turnpoints(x) > extract(tp, no.tp = FALSE, peak = TRUE, pit = FALSE) [1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE Warning message: arguments after the first two are ignored in: UseMethod("extract", e, n, ...) >