Displaying 20 results from an estimated 7000 matches similar to: "axis lines crossing at origin"
2004 Jun 11
4
rownames of single row matrices
Hi
I want to extract rows of a matrix, and preserve rownames even if only
one row is selected. Toy example:
R> a <- matrix(1:9,3,3)
R> rownames(a) <- letters[1:3]
R> colnames(a) <- LETTERS[1:3]
R> a
A B C
a 1 4 7
b 2 5 8
c 3 6 9
Extract the first two rows:
R> wanted <- 1:2
R> a[wanted,]
A B C
a 1 4 7
b 2 5 8
rownames come through fine. Now extract just
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 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 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 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 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 Oct 06
3
crossprod vs %*% timing
Hi
the manpage says that crossprod(x,y) is formally equivalent to, but
faster than, the call 't(x) %*% y'.
I have a vector 'a' and a matrix 'A', and need to evaluate 't(a) %*% A
%*% a' many many times, and performance is becoming crucial. With
f1 <- function(a,X){ ignore <- t(a) %*% X %*% a }
f2 <- function(a,X){ ignore <-
2004 Jul 05
1
"make" error for R-1.9.1
Hello everybody.
I am trying to upgrade from R-1.9.0 to R-1.9.1 on a RedHat linux
2.4.18 system. I get
the following error after "tar -xvzf R-1.9.1.tgz ; cd ./R-1.9.1/ ; ./configure"
and "make" :
[make works for 10 minutes ... snip ...]
varExp text html latex
varFixed text html latex
varFunc
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 <-
2004 May 25
2
vectorize an expression
Hi guys. Another thing I cannot vectorize:
I have an array "a", of size 5-by-2, for example, of 5 2D vectors. I
also have a distance function that computes the distance between two
vectors (usual Euclidean distance is a good example but I have other metrics I
want to use as well). I want a 5-by-5 array with the [i,j]th element being
the distance from a[i,] to a[j,]
To Wit:
a
2004 Mar 10
3
aperm() and as.list() args to "["
Hi everyone.
I'm playing with aperm():
a <- 1:24
dim(a) <- c(2,3,2,2)
permutation <- c(1,2,4,3)
b <- aperm(a,permutation)
So if my understanding is right,
a[1,3,2,1] == b[c(1,3,2,1)[permutation] ]
but this isn't what I want because the RHS evaluates to a vector, and
I am trying to identify a single element of b.
How do I modify the RHS to give what I want?
Following
2004 Mar 12
1
another do.call() problem.
Hi everyone
suppose I have
a <- array(1:256,rep(4,4))
and want to access a[1,2,3,1] by the vector c(1,2,3,1). As per
yesterday, I can use do.call():
a[1,2,3,1] == do.call("[",c(list(a),c(1,2,3,1)))
Now how do I apply the above technique (or indeed any other technique!) to get
a[1,2,3,]
[1] 37 101 165 229
from a vector like c(1,2,3,0) or c(1,2,3,NULL) or c(1,2,3,NA)?
2004 Mar 19
5
asp=1 and aspect ratio
Hi everyone
I want a square scatterplot with abline(0,1) going exactly through the
SW and NE corners. By "square" I mean that the plotting region is
exactly square, and that the axis limits are identical.
x <- 1:20
y <- x+rep(c(-1,1),10)
lims <- range(c(x,y))
None of the following do this:
plot(x,y) ; abline(0,1) #not square
plot(x,y,asp=1);abline(0,1) #diagonal
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
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 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 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
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