similar to: rownames of single row matrices

Displaying 20 results from an estimated 7000 matches similar to: "rownames of single row matrices"

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:
2004 Nov 15
2
argument rationalization
Hi I am writing a bunch of functions that take two, three or four arguments. These functions operate on vectors of the same length; but I want the function to behave sensibly if one or more arguments are scalars. "+" does this for two arguments: "+"(1:10,3) # interpreted as "+"(1:10,rep(3,10)) But my functions can take more arguments. Say f() takes three:
2004 Nov 17
3
3d scatter plot with drop line
This is a follow up to my question from yesterday. I want to do in R what is called a "3d scatter plot with drop lines" in S-PLUS. Basically, it's a 3dscatterplot with lines connecting the x-y grid to the z points. The lines give a better perspective on the shape of the data surface. How to? Joel Bremson UC Davis Statistics
2004 May 27
2
block diagonal matrix function
Hello List I have just written a little function that takes two matrices as arguments and returns a large matrix that is composed of the two input matrices in upper-left position and lower-right position with a padding value everywhere else. (function definition and toy example below). I need nonsquare matrices and rowname() and colname() inherited appropriately. Two questions: (1) Is there a
2004 Oct 18
2
concatenating lists elementwise
Hi How do I concatenate two lists element-by-element? Example: list.1 <- list(temperature=c("hot","cold") , size=c("big","medium")) list.2 <- list(temperature=c("lukewarm") , size=c("massive","tiny")) list.wanted <- list(temperature=c("hot","cold","lukewarm") ,
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
2004 Nov 11
1
axis lines crossing at origin
Hi how do I make my axes cross at the origin? x <- seq(from=-pi,to=pi,len=30) plot(x,sin(x)) makes the axes cross at about (-pi,-1). How do I get my x and y axes to cross in the centre of the graph, with the sine curve passing through the intersection? I couldn't find anything in ?par or ?axis; searching R-FAQ for "axis" didn't help. -- Robin Hankin Uncertainty
2004 Sep 13
1
Rd files with "%" (was: permuting dimensions)
Professor Ripley thanks for this. Very much appreciated. The original subject line reflected my late-night conviction that the answer might involve passing a strange list to do.call(). Anyway, package magic is broken (only in R-devel, I might add) because I have a function called "%eq%". R-2.0.0 CMD check is stopping (I think) because it interprets the "%" as a
2004 Sep 15
6
Bessel function
Dear all Currently, I'm implementing the generalized hyperbolic distribution into Splus. Unfortunately the Bessel function is not implemented in Splus. In R the Bessel function does exist but it is an internal function and I'm not able to look at the code. Is there any possibility to see the code of the Bessel function in R or does anybody has an implementation of the Bessel function in
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 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 Jul 27
4
inserting rows into a matrix
Hi I have a little vector function that takes a vector A of strictly positive integers and outputs a matrix M each of whose columns is the vector, modified in a complicated combinatorical way. Now I want to generalize the function so that A can include zeroes. Given A, I want to strip out the zeroes, pass it to my function, and pad M with rows at positions corresponding to the zeroes
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,
2005 Jun 20
6
sweep() and recycling
Hi I had a hard-to-find bug in some of my code the other day, which I eventually traced to my misusing of sweep(). I would expect sweep() to give me a warning if the elements don't recycle nicely, but X <- matrix(1:36,6,6) sweep(X,1,1:5,"+") [,1] [,2] [,3] [,4] [,5] [,6] [1,] 2 9 16 23 30 32 [2,] 4 11 18 25 27 34 [3,] 6 13 20 22
2007 Jan 16
5
"[[" gotcha
The following gotcha caught me off-guard just now. I have two matrices, a and b: a <- matrix(1,3,3) b <- matrix(1,1,1) (note that both "a" and "b" are matrices). I want them in a list: > B <- NULL > B[[1]] <- a > B[[2]] <- b > B [[1]] [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 [[2]] [,1] [1,] 1
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
2006 Oct 13
5
combinatorics
Hi How do I generate all ways of ordering sets of indistinguishable items? suppose I have two A's, two B's and a C. Then I want AABBC AABCB AACBC ABABC . . .snip... BBAAC . . .snip... CBBAA [there are 5!/(2!*2!) = 30 arrangements. Note AABBC != BBAAC] How do I do this? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14
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 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 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("+",