Displaying 20 results from an estimated 7000 matches similar to: "inherits() and virtual classes"
2005 Aug 31
3
generic function argument list problem
Hi
it says in R-exts that
A method must have all the arguments of the generic,
including ... if the generic does.
A method must have arguments in exactly the same order as the
generic.
A method should use the same defaults as the generic.
So, how come the arguments for rep() are (x, times, ...) and the
arguments
for rep.default() are (x, times, length.out, each, ...) ?
2005 Jul 29
1
octonions
Hi
I thought it would be fun to develop R functionality for
the octonions (there is already some work on quaternions).
The octonions are an 8 dimensional algebra over the reals, so an
octonion
may nicely be represented as a real vector of length 8. Applications
are many and varied, mostly quantum mechanics.
I would like to develop some R functionality in this area.
My first problem is how
2005 Jun 13
3
extracting components of a list
Hi
how do I extract those components of a list that satisfy a certain
requirement? If
jj <- list(list(a=1,b=4:7),list(a=5,b=3:6),list(a=10,b=4:5))
I want just the components of jj that have b[1] ==4 which in this case
would be the first and
third of jj, viz list (jj[[1]],jj[[3]]).
How to do this efficiently?
My only idea was to loop through jj, and set unwanted components to
NULL,
2006 Sep 01
1
as.environment(NULL)
Hi
In NEWS, it says
R CMD check now tests that the package can be loaded, and that
the package and namespace (if there is one) can each be loaded
in startup code (before the standard packages are loaded).
For package "onion", I think I have followed all of
sections 1.6.1 - 1.6.6 of R-exts, and it passes R CMD check for
R-2.3.1.
However, using R version 2.4.0 Under
2005 Sep 09
2
two almost identical packages: best practice
Hi
I have written a whole bunch of methods for objects of class "octonion".
[
an octonion is a single column of an eight-row matrix. Octonions have
their own multiplication rules and are a generalization of quaternions,
which are columns of a four-row matrix.
]
So far I've done about a dozen generic functions such as seq.octonion(),
rep.octonion(), [<-.octonion(), and so on
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)}
2004 Sep 08
3
do.call("[", ...) question
Hi again everyone
I have an arbitrarily dimensional array "a" and a list "jj" of length
length(dim(a)). The elements of jj are vectors of indexes.
How do I use do.call() to extract a[ jj[[1]], jj[[2]], jj[[3]], ...] ?
Toy example follows:
a <- matrix(1:30,5,6)
jj <- list(5:1,6:1)
I want the following
a[ jj[[1]],jj[[2]] ]
How do I do this?
OBAttempts:
2007 Apr 17
1
no visible binding for global variable
Hello everyone
I am trying to get one of my packages through R's QC.
The package is clean for me under R-2.4.1, R-2.5.0, and
R-devel, but Kurt gets
>
> * checking R code for possible problems ... WARNING
> hypercube: no visible binding for global variable ?f?
Function hypercube() [cut-&-pasted below] is intended to
return an adjacency matrix for an n-dimensional
2004 Jan 14
1
arrows on contour lines
Hello everybody
I'm using contour() to draw streamlines of potential flow, eg
jj <- seq(from= -4, to=4,len=20)
jj <- outer(jj,jj,function(x,y){x})+1i*outer(jj,jj,function(x,y){y})
f <- function(x){x^2}
contour(Im(f(jj)), nlevels=44 , labels="")
How best to put arrows on the contour lines to show the direction of flow?
(ie I want contour lines looking like
2005 Feb 07
4
proportional matrix rows
Hi
I have a two-column integer matrix like this:
R> jj
[,1] [,2]
[1,] -1 1
[2,] -2 2
[3,] -7 6
[4,] -8 7
[5,] -6 5
[6,] -9 8
[7,] -5 4
[8,] 3 -3
[9,] -10 9
[10,] -4 3
I want a diagnostic that detects whether a row is a multiple of
the first row or not. In this case, this would be rows 1,2, and 8.
How to do this
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
2008 Apr 02
1
"[<-" plus drop-type extra argument
Hello
I am writing a replacement method for an S4 class and want to pass
an additional argument to "[<-"() along the lines of "["()'s "drop"
argument.
Specifically, I have an S4 class, call it "foo", with a slot 'x'
that is a
vector and a slot 'NC' that is a scalar.
I want to be able to pass a Boolean argument to the
2006 Jul 10
1
par(mfrow,mai) and multiple plot problem
Hi
I'm having difficulty with a multiple plot. What I want is 12
plots, all of which are the same size and shape, differing
only in colour. Each one is a square, so there is an asp=1
in the plot call. I'm working in an Sweave environment so I
am free to choose the height and width of the plot.
I want the columns to be labelled at the head (here t=1,2,3)
and the rows to be labelled at
2007 Dec 19
3
array addition
Hi
suppose I have two arrays x1,x2 of dimensions a1,b1,c1 and
a2,b2,c2 respectively.
I want x = x1 "+" x2 with dimensions c(max(a1,a2), max(b1,b2),max
(c1,c2))
with
x[a,b,c] = x1[a1,b1,c1] + x2[a2,b2,c2] if a <=min(a1,a2) , b<=min
(b1,b2), c<=min(c1,c2)
and the other bits either x1 or x2 or zero according to whether the
coordinates
are "in range" for
2005 Dec 05
1
apply() and dropped dimensions
Hi
I am having difficulty with apply(). I want apply() to return a
matrix, but sometimes a vector is returned.
Toy example follows.
Function jj() takes a couple of matrices m1 and m2 as arguments
and returns a matrix with r rows and c columns where r=nrow(m2)
and c=nrow(m1).
jj <- function(m1,m2,f,...){
apply(m1, 1, function(y) {
apply(m2, 1, function(x) {
f(x, y, ...)
2005 Oct 21
0
new package bundle: onion
Dear List
I have just uploaded a new package, "onion", to CRAN.
It provides some functionality for manipulating and visualizing
quaternions
and octonions.
All comments welcome!
enjoy
rksh
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
_______________________________________________
2005 Oct 05
2
eliminate t() and %*% using crossprod() and solve(A,b)
Hi
I have a square matrix Ainv of size N-by-N where N ~ 1000
I have a rectangular matrix H of size N by n where n ~ 4.
I have a vector d of length N.
I need X = solve(t(H) %*% Ainv %*% H) %*% t(H) %*% Ainv %*% d
and
H %*% X.
It is possible to rewrite X in the recommended crossprod way:
X <- solve(quad.form(Ainv, H), crossprod(crossprod(Ainv, H), d))
where quad.form() is a little
2004 Oct 26
1
persp(), scatterplot3d(), "..." argument
Hello list.
I very often need 3d scatterplots, and use scatterplot3D quite a lot.
I am trying to modify persp() to plot scatterplots, and make use of
the theta and phi arguments that persp() offers. I am having some
difficulty passing the correct arguments to persp().
Here is my function so far. Much of it is copied from the persp() manpage.
points3d <- function(x,y,z,
2004 Oct 26
1
persp(), scatterplot3d(), "..." argument
Hello list.
I very often need 3d scatterplots, and use scatterplot3D quite a lot.
I am trying to modify persp() to plot scatterplots, and make use of
the theta and phi arguments that persp() offers. I am having some
difficulty passing the correct arguments to persp().
Here is my function so far. Much of it is copied from the persp() manpage.
points3d <- function(x,y,z,
2006 Nov 15
2
filling an array, vectorized
Hi,
I am sure this has come up before, but my searches of the archive
didn't give any results (maybe I didn't use the right keywords, but if
I use too many, the search times out).
I have a vector of dimensions n, length is not fixed, eg
n <- c(4,5,7)
or
n <- c(19,4,5,7)
and a function f that takes a vector of indices, same length of n, and
gives a scalar.
I would like to fill