similar to: which operators are available? (was: Re: do.call("+", ...))

Displaying 20 results from an estimated 8000 matches similar to: "which operators are available? (was: Re: do.call("+", ...))"

2006 Nov 17
2
do.call("+", ...)
Hi How do I make do.call() take "+" as a function for a list of more than two elements? Toy problem follows: f <- function(i){matrix((1:6)^i,2,3)} # Thus f() returns a matrix of size 2x3; I want to add a whole bunch of such matrices, # as in f(1) + f(2) + f(3) + f(4) # But: > do.call("+",sapply(1:4,f,simplify=FALSE)) Error in do.call("+",
2005 Mar 30
3
Recall() and sapply()
Hi. I'm having difficulty following the advice given in help(Recall). Consider the two following toy functions: f1 <- function(n){ if(length(n)>1){return(sapply(n,f1))} matrix(n,n,n) } f2 <- function(n){ if(length(n)>1){return(sapply(n,Recall))} matrix(n,n,n) } f1() works as desired (that is, f(1:3), say, gives me a three element list whose i-th element is an
2010 Oct 26
1
S4 methods for rbind()
Hello. I am trying to write an S4 method for rbind(). I have a class of objects called 'mdm', and I want to be able to rbind() them to one another. I do not want the method for rbind() to coerce anything to an mdm object. I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any number of arguments]. This is what I have so far: setGeneric(".rbind_pair",
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
2006 Apr 06
1
R CMD check for packages in a bundle
Hi [MacOsX 10.4.6; R-2.2.1] I have a bundle that comprises three packages. I want to run R CMD check on each one individually, as it takes a long time to run on all three. I am having problems. The bundle as a whole passes R CMD check, but fails when I cd to the bundle directory and run R CMD check on a package directory. The whole bundle passes: octopus:~/scratch% R CMD check
2005 Oct 19
3
diag() problem
Hi I have a matrix "u", for which diag() gives an error: u <- structure(c(5.42334674128216, -2.31319389204264, -5.83059042218476, -1.64112369640695, -2.31319389212801, 3.22737617646609, 1.85200668021569, -0.57102273078531, -5.83059042231881, 1.85200668008156, 11.9488923894962, -3.5525537165941, -1.64112369587405, -0.571022730886046, -3.55255371755604,
2005 Dec 08
1
kronecker(... , make.dimnames=TRUE)
Hi I'm using kronecker() with a matrix and a vector. I'm interested in the column names that kronecker() returns: > a <- matrix(1:9,3,3) > rownames(a) <- letters[1:3] > colnames(a) <- LETTERS[1:3] > b <- c(x=1,y=2) > kronecker(a,b,make.dimnames=TRUE) A: B: C: a:x 1 4 7 a:y 2 8 14 b:x 2 5 8 b:y 4 10 16 c:x 3 6 9 c:y 6 12 18 > The
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 Jul 13
2
Kronecker matrix product
Hi I want to write a little function that takes a matrix X of size m-by-n, and a list L of length "m", whose elements are matrices all of which have the same number of columns but possibly a different number of rows. I then want to get a sort of dumbed-down kronecker product in which X[i,j] is replaced by X[i,j]*L[[j]] where L[[j]] is the j-th of the "m" matrices. For
2006 Feb 28
2
lines() and recycled colours
Hi ?lines says For 'type = "h"', 'col' can be a vector and will be recycled as needed. Why doesn't lines() recycle colours for other types? If I type > plot(0:1,0:1,type="n") > lines(runif(11),runif(11),col=c("red","green")) > then all ten lines are red, with no warning given. Is there a reason why
2006 Jul 26
2
largest acceptable lookup table in a package
Hi One of my packages needs a look-up table of pre-calculated numbers in the data directory. I would like to have the matrix as large as possible. What is the largest size matrix that would be an acceptable datafile in an R package? [ The table is a square, upper triangular matrix consisting of logs of Stirling numbers calculated by Maple. As discussed on the List a few days ago (thanks
2006 Feb 22
3
elements that appear only once
Hi. I have a factor and I want to extract just those elements that appear exactly once. How to do this? Toy example follows. > a <- as.factor(c(rep("oak",5) ,rep("ash",1),rep("elm",1),rep ("beech",4))) > a [1] oak oak oak oak oak ash elm beech beech beech beech Levels: ash beech elm oak > table(a) a ash beech elm oak
2006 May 22
1
R CMD check problem
Hi I have a package that I'm testing. It seems to install fine and it works, as far as I can tell. For example, I can install the package, and use it, and source the test suite with no errors. My problem is with R CMD check. It passes on R-2.2-0: Robin-Hankins-Computer:~/scratch% R CMD check ./partitions_1.1-0.tar.gz * checking for working latex ... OK [snip] make[1]: Leaving directory
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,
2005 Sep 21
3
size of subplots with par() / layout()
Hi If I do this: par(mfrow=c(2,2)) persp(matrix(1:4,6,6),box=F,phi=33,theta=33) persp(matrix(1:4,6,6),box=F,phi=33,theta=33) persp(matrix(1:4,6,6),box=F,phi=33,theta=33) persp(matrix(1:4,6,6),box=F,phi=33,theta=33) ( or indeed layout(matrix(1:4,2,2)) persp . . . . ) then the mesh plots look too small to me. How do I make them larger? -- Robin Hankin Uncertainty Analyst National
2006 Jul 25
2
pari/gp interface
Hi I'm developing an R package that needs to execute some code written in pari/gp. I've used this before from an R package (elliptic) but the interface is very basic: the R function creates a string such as the following: string <- echo ' ellwp ([ 2+0*I , 0+2*I ], 1+0*I )' | gp -q And then system(string) returns the output from gp which then needs to be text processed
2007 Mar 19
3
character to numeric conversion
Hi. Is there a straightforward way to convert a character string containing comma-delimited numbers to a numeric vector? In my application, I use system(executable.string, intern=TRUE) which returns a string like "[0.E-38, 2.096751179214927596171268230, 3.678944959657480671183123052, 4.976528845643001020345216157, 6.072390165503099343887569007, 7.007958550337542210168866070,
2006 Sep 13
3
functions and strings
Hi If string <- "xyz" f <- function(x){1 + sin(cos(x)) + exp(x^2)} How do I manipulate "string" and f() to give the string "1 + sin(cos(xyz)) + exp(xyz^2)" ? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
2005 Apr 13
2
Inf +1i vs 1+Inf*1i
Hi If I have a <- Inf + 1i then Re(a) is Inf, and Im(a) is 1, as expected. But if b <- 1 + Inf * 1i, then Im(b) = Inf , as expected, but Re(b) = NaN, which I didn't expect. Why this asymmetry? How to define an object with Re(b)=1, Im(b)=Inf? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
2006 May 23
1
package installation problem
(this after asking the package author) Hi I cannot install the rmvnorm package under R-2.3.0, or R-2.3.1 beta. It installs fine under R-2.2.1. transcript for installation under R-2.3.0 follows. Robin-Hankins-Computer:~/scratch% R --version R version 2.3.0 (2006-04-24) Copyright (C) 2006 R Development Core Team R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to