similar to: no visible binding for global variable

Displaying 20 results from an estimated 8000 matches similar to: "no visible binding for global variable"

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,
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 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?
2007 Jun 27
1
inherits() and virtual classes
Hi How do I test for an object having a particular virtual class? In the following, "onion" is a virtual class, and "octonion" is a non-virtual class contained in onion. The last call to inherits() gives FALSE [R-2.5.0], when inherits.Rd led me to expect TRUE. setClass("onion", representation = "VIRTUAL" )
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
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
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
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, ...)
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
2007 Jul 10
2
integration over a simplex
Hello The excellent adapt package integrates over multi-dimensional hypercubes. I want to integrate over a multidimensional simplex. Has anyone implemented such a thing in R? I can transform an n-simplex to a hyperrectangle but the Jacobian is a rapidly-varying (and very lopsided) function and this is making adapt() slow. [ A \dfn{simplex} is an n-dimensional analogue of a triangle or
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
2004 Oct 01
2
multiple dimensional diag()
Hi I have two arbitrarily dimensioned arrays, "a" and "b", with length(dim(a))==length(dim(b)). I want to form a sort of "corner-to-corner" version of abind(), or a multidimensional version of blockdiag(). In the case of matrices, the function is easy to write and if a=matrix(1,3,4) and b=matrix(2,2,2), then adiag(a,b) would return: [,1] [,2] [,3] [,4] [,5]
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
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
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