Displaying 20 results from an estimated 6000 matches similar to: "deparse, substitute and S4 generics"
2007 Jul 25
2
initalizing and checking validity of S4 classes
Dear useRs and wizaRds,
I am currently developing a set of functions using S4 classes. On the way I encountered the problem exemplified with the code below. For some reason the 'validity' method does not seem to work, i.e. does not check for errors in the specification of the slots of the defined class. Any hints?
My understanding of the whole S4 system was that validity checks are made
2006 Jun 23
2
problem with hist() for 'times' objects from 'chron' package
Hello dear useRs and wizaRds,
I encountered the following problem using the hist() method for the
'times' classes
from package 'chron'. You should be able to recreate it using the code:
library(chron)
# pasted from chron help file (?chron)
dts <- dates(c("02/27/92", "02/27/92", "01/14/92", "02/28/92",
"02/01/92"))
class(dts)
2007 Jan 25
1
using non-ASCII strings in R packages
Hello dear useRs and wizaRds,
I am currently developing a package that will enable to use administrative map of Poland in R plots. Among other things I wanted to include region names in proper Polish language so that they can be used in creating graphics etc. I am working on Windows and when I build the package it is complaining about non-ASCII characters R code files.
I was wondering what would
2012 Feb 04
1
'deparse(substitute'))' then 'assign' in a S4 methods
Hi the list,
I am writing a function in which I need to affect a variable on a higher
level. My fnction could be:
++++++++++++++++++
fooBis <- function(x){
nameObject <- deparse(substitute(x))
print(nameObject)
assign(nameObject,4,envir=parent.frame())
}
> fooBis(e)
[1] "e"
> e
[1] 4
-----------------
(to simplify, this fnction can affect only the number
2007 Mar 13
4
'substitute' question
# I use this code to label a graph with the R2:
# graph
x <- rnorm(100)
y <- x + rnorm(100)
lm1 <- lm(y~x)
plot(x,y)
# label
R2text <- substitute(paste(R^2," = ",r2),list(r2=r2))
text(1,-3,R2text, col="red")
# i have modified this a bit, so that i have a vector with other labels,
each of which
# will be labelled on the graph. Example:
texts <- c("And the
2006 Oct 19
1
default arguments in generics and methods
i believe the following is true but would appreciate confirmation
that it is intended behavior and will continue:
if a default argument is employed in the definition of a generic
function, and the generic is called with the argument in question
(call it 'ARG') missing, then the method for signature (..., ARG =
"missing", ...) will be called by 'standardGeneric'
2006 Oct 11
1
dispatching on group generics with more than one formal
please see the code below. foo2 fails to dispatch correctly, but foo
does fine. i have tried 'cacheMetaData(1)' and a number of different
variants of 'cacheGenericsMetaData', on the possibility there is a
caching issue. but i still can't sort it out.
also one general question: does it really matter what's in the body
of the function definition in a
2007 Jun 02
3
Updating R version
A quick question. I am trying to understand how I could move the installed
packages in my R 2.3 version to the newly installed R 2.5 version, without
having to install all the packages again. I copied the files under the old
library subdirectory to the new library subdirectory. But still the newer
version is not recognizing the packages that were copied over.
Thanks.
[[alternative HTML version
2002 May 08
1
Questions about S4 style methods and generics
I have some questions about S4 style methods and generics.
First of all, is there any way of using default values for arguments
in the generics/methods? My own experiments show that such arguments
are always ignored. The green book seems to be silent on this
matter.
The second question is about using a non-trivial function body for
generics. Page 351 of the green book gives an example of this
2008 Nov 25
2
dots methods: dispatch issues
There seems to be a bug arising when using multiple S4 generics with "..."
as the signature.
The following code works as expected:
##############################################################
> setGeneric("rbind", function(..., deparse.level=1)
standardGeneric("rbind"),
+ signature = "...")
Creating a generic for "rbind" in
2006 Jan 25
2
Using substitute from inside an S4 method
Hi all,
I would like to access the name of a variable passed to an S4 method.
For a function, I would do this:
f <- function(x) as.character(substitute(x))
This also works for a the examples I have tried for methods that do
not have extra, non-dispatch args:
setGeneric("A", function(x, ...) standardGeneric("A"))
setMethod("A",
2007 Jan 31
2
Problems with definitions of S4-generics
Hello all,
I'd like to report a problem related to S4 classes.
Platform:
Mac G4/400 PCI (PPC-architecture)
Mac OS 10.4.8
R 2.4.1 for Mac OS X (CRAN binary, 2006-12-19) w/ R.app 1.18
Last December, Simon Urbanek confirmed that the issue is not platform
related, and that it is most likely a bug. He suggested to post my report
to "the appropriate mailing list" -- I choose r-devel.
2008 Mar 13
3
Sealed for setGeneric
Hi the list
When two setGeneric occurs on the same function, the second erage the
first and erase all the function previously define.
Is it possible to prevent that ? Is it possible to declare a setGeneric
that can not be erased later ?
Something like the |sealed for setMethod...|
||
|Thanks|
||
Christophe
2014 Jul 11
1
Namespaces and S4 Generics
I've installed R-devel
R Under development (unstable) (2014-07-09 r66111)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
and am trying to resolve some problems that I am seeing with my
SparseM package. In prior versions I explicitly had:
setGeneric("image", function(x, ...) standardGeneric("image"))
and then used setMethod to define a method for the class matrix.csr
but
2005 Dec 29
1
trouble with S4 methods for group "Summary"
Hello. This question concerns the Methods package. I have created a
new class and am trying to set a method for it for S4 group generic
"Summary". I have run into some signature problems. An example:
> setClass("track", representation(x="numeric", y="character"))
[1] "track"
> setGeneric("max", group="Summary")
2007 Mar 08
1
sink with R-code
I have the same question that Eusebio had:
Is there a function similar to "sink" that redirect also R code to a
file that
is:
sink("R001")
x <- c(2,-6,-4,8,5,4,1,3,4,-9,0,1)
A <- matrix(x, ncol=3)
A
A.prima <- t(A)
A.prima
dim(A)
dim(A.prima)
sink()
create a file "R001" with contents:
------------------------------------------
[,1] [,2] [,3]
[1,]
2007 Mar 08
1
Searching and deleting elements of list
Hi,
I have a problem. Please, look at example and try to help me!!
> A<-c("aaa","bbb","ccc","ddd","eee")
> B<-c("vvv","ooo","aaa","eee","zzz","bbb")
> C<-c("sss","jjj","ppp","ddd")
> D<-c("bbb","ccc")
2008 Jan 23
1
Package Building and Name Space
Hello,
I just don't get this and would appreciate if someone could write a line or
two: I'm trying to build this package and it stops installing after I add
the following to the NAMESPACES file:
>importFrom(gsubfn,strapply)
The error during the package test is:
Error in MyPackage::MyFunction :
package 'MyPackage' has no name space and is not on the search path
Calls:
2005 Aug 03
1
deparse(substitute(x)) and S3 methods
Dear List,
I have the following function:
coca <- function(x, ...)
{
if(is.null(class(x))) class(x) <- data.class(x)
UseMethod("coca", x)
}
and a default method
coca.default <- function(x, y, method = c("predictive", "symmetric"),
reg.method = c("simpls", "eigen"), weights =
NULL,
2005 Mar 25
1
S4 methods semantics questions
Some quick questions about S4 methods.
Does the typing of S4 methods mean that lazy evaluation is no longer
possible? It seems that you would need to evaluate the arguments to
determine their type at dispatch.
Second, what role, if any, do default arguments play in S4 methods? I
notice that you can put default arguments into generics but that the
dispatch is still done on the type of the