Displaying 20 results from an estimated 5000 matches similar to: "Dummy's guide to S4 methods: package Brobdingnag"
2006 Sep 15
1
setMethod() woes
Hello everybody
R version 2.4.0 alpha (2006-09-15 r39323), MacOSX 10.4.7
Next S4 problem.
I have "brob" objects that are large real numbers, and now I want "glub"
numbers that are to be a pair of glubs that represent complex numbers.
I want to define binary operator "+" so that if either the left or right
argument are glubs, it uses .ArithGlub.
If either
2006 Oct 31
1
setReplaceMethod
Hi
If x <- 1:10 then x[5] <- 1i will promote
x to be a complex vector.
Suppose I have an S4 class "brob", and have functions
is.brob(), as.brob(), as.numeric() and so forth (minimal self-contained
code below).
If x is numeric (1:10, say) and y is a brob, what
is the best way to make
x[5] <- y
promote x to a brob in the same way as the complex example?
Or is
2006 Sep 01
1
setMethod("Logic", ...)
Hi
In V&R the "polynomial" class is explicitly specified to have no
logical operators:
setMethod("Logic", signature(e1="polynomial"), function(e1,e2){stop
("...")})
I too have a class of objects for which I want to
specify that Logic operators do not work, but executing
setClass("brob",
representation = representation
2006 Sep 04
1
setMethod("Summary")
Hi everyone and thanks for being patient. I've used "!.foo"() et
seq pro tem.
Next problem: how to define "Summary" methods for brobs.
?max says
'max' and 'min' are generic functions: methods can be defined for
them individually or via the 'Summary' group generic. For this to
work properly, the arguments '...' should be
2006 Aug 30
1
setMethod() and log()
Hi
I am having difficulty with setMethod(). I have a "brob" class of
objects whose
representation has two slots: "x" and "positive". Slot "x" (double)
holds the log
of a number and slot "positive" (logical) its sign. The idea is
that large numbers
can be handled.
I'm trying to implement a log() method using an analogue of the
2006 Sep 12
1
package.skeleton() in R-2.4.1
Hi
R version 2.4.0 alpha (2006-09-06 r39158)
MacOSX 10.4.7
There was a thread some time ago as to whether the structure created by
package.skeleton() would pass R CMD check.
I have an example where package.skeleton() gives an R file that gives an
error when sourced.
If I type
setClass("brob",
representation = representation
2007 Aug 30
7
Behaviour of very large numbers
Dear all,
I am struggling to understand this.
What happens when you raise a negative value to a power and the result
is a very large number?
B
[1] 47.73092
> -51^B
[1] -3.190824e+81
# seems fine
# now this:
> x <- seq(-51,-49,length=100)
> x^B
[1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN <snip>
> is.numeric(x^B)
[1] TRUE
> is.real(x^B)
[1]
2008 May 28
1
indexing lists, using brobdingnagian
Dear R-Gurus,
I have ended up with a calculation problem where I need to use brobs.
I have to work my way through a vector with a for loop to act on each
element in a calculation (refering to the previous
value in the new vector of results -- so as far as I know I can't use
"apply") -- this produces a list of brobs.
My problem is, how do I act on, plot this list, or do vector
2006 Aug 29
0
S4 methods for "+"
On 25 Aug 2006, at 12:56, Prof Brian Ripley wrote:
> Just like any other S4 method:
>
> setMethod("+", c("track", "track"),
> function(e1, e2) new("track", x=c(e1 at x, e2 at x), y=c
> (e1 at y,e2 at y)))
>
> If you want to write a group generic for the S4 Ops group, you do it
> very like S3. There are worked examples in
2006 Aug 29
2
vector S4 classes
In the Green Book, section 7.5 discusses new vector classes and uses
quaternions
as an example of a vector class that needs more than one number per
element.
I would like to define a new class that has a numeric vector and a
logical
vector of the same length that specifies whether the measurement was
accurate.
The following code does not behave as desired:
>
2008 Jan 07
2
S3 vs S4 for a simple package
I am writing a package and need to decide whether to use S3 or S4.
I have a single class, "multipol"; this needs methods for "[" and "[<-"
and I also need a print (or show) method and methods for arithmetic +-
*/^.
In S4, an object of class "multipol" has one slot that holds an array.
Objects of class "multipol" require specific arithmetic
2008 Sep 16
0
FW: odesolve dynload example
HI R Gurus,
> This is my first foray into using c-code with R, so ...
> I had a look at the archives and did not find anything on this, so
> hopefully I am not doubling up.
>
I have previously used the following approach where I needed some very
small numbers/large (using Brobdingnag):
surfacewithdiff <- function(t, y, p)
{
const=p["const"]
kay
2008 Sep 16
0
lsoda( linking to GMP for big numbers from C code)
Hi R used with C-code experts,
I had a look at the archives and did not find anything on this, so
hopefully I am not doubling up.
I have previously used the following approach where I needed some very
small/large numbers (using Brobdingnag):
surfacewithdiff <- function(t, y, p)
{
const=p["const"]
kay =p["kay"]
psii=p["psii"]
2008 Mar 26
5
S4 slot with NA default
Hi
How do I specify an S4 class with a slot that is potentially numeric,
but NA
by default? I want the slot to be NA until I calculate its value
(an expensive operation, not needed for all applications). When
its value is
known, I will create a new object with the correct value inserted in
the slot.
I want "NA" to signify "not known".
My attempt fails because
2007 Oct 05
3
R-2.6.0 package check problems
Hello
One of my packages, untb_1.3-2, passes R CMD check under
MacOSX (and apparently the systems used in the package check
summary page on CRAN) but fails with the following message on
R-2.6.0.tgz compiled last night on my (home) linux box. I hasten
to add that I have never seen this error before on home-compiled
pre-releases of R-2.6.0.
Can anyone help me understand what is going on?
2004 Nov 18
0
Fwd: Re: 3d scatter plot with drop line
Hi
try this:
p3dpairs <- function(x,x1,
xlim=NULL,ylim=NULL,zlim=NULL,col=par("col"), pch=par("pch"),
cex=par("cex"), ...){
if(is.matrix(x)){
z <- x[,3]
y <- x[,2]
x <- x[,1]
}
if(is.matrix(x1)){
z1 <- x1[,3]
y1 <- x1[,2]
x1 <- x1[,1]
}
if(missing(zlim)) {
z.grid <-
2005 Jan 07
1
Visualizing complex analytic functions using domain coloring
Hi
has anyone coded up domain colouring for visualizing complex analytic
functions
(such as elliptic functions)?
[
the idea is to depict a complex function f(z) using a filled.contour()
variant
in which the hue is given by Arg(f(z)), and the saturation by Mod(f(z)).
]
--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
tel
2005 Apr 29
1
accuracy of test cases
Hi
I have several methods for evaluating a function. The methods are
algebraically
identical but use different numerical techniques. The different methods
work
better (converge faster, etc) in different parts of the function's
domain.
I am compiling a test suite for a package, and would like to verify
that the
different methods return approximately identical results.
Toy example
2005 Jul 04
1
prototypes for z_sin() and z_cos()
Hi
I have been looking at complex.c and want to access z_cos() and z_sin
() from
C in one of my packages.
There doesn't seem to be a corresponding header file: there is no
complex.h file.
Where are the prototypes of z_sin() and z_cos() for these functions?
grepping didn't help me:
find ~/downloads/R-2.1.1/ -name "*.h " | xargs
egrep "z_cos"
2005 Sep 01
1
generic function S3 consistency warning advice
Hi
section 6.1 of R-exts suggests that a package can take over a
function in the base
package and make it generic.
I want to do this with Re() and have the following lines in my R code:
"Re" <- function(x){UseMethod("Re" )}
"Re.default" <- get("Re" ,pos=NULL,mode="function")
"Re.octonion" <- function(x){give.comp(x,1)}