similar to: How to set an argument such that a function treats it as missing?

Displaying 20 results from an estimated 40000 matches similar to: "How to set an argument such that a function treats it as missing?"

2010 Dec 29
2
How to create an array of lists of multiple components?
Hi, how can I create an array of lists of three components? This approach does not work: n1 <- 2 n2 <- 4 n3 <- 5 res <- array(rep(vector("list",3), n1*n2*n3), dim = c(n1,n2,n3)) res[1,1,1] # is not a list with three components... The goal is that res[1,1,1] is a list with three components. Also, appending the components didn't work. For example, I tried: component
2010 Nov 26
3
lattice: strange behavior (?) when using trellis.device(color=FALSE)
Dear expeRts, I am not sure if I found a bug... I would like to create a function that itself creates a lattice plot without colors. Following http://www.mail-archive.com/r-help at r-project.org/msg64699.html I use trellis.device() to set the colors to FALSE. Whenever I call the minimal example below *with* trellis.device(), Quartz opens a window (I am working on a MAC), which it shouldn't,
2010 Nov 26
1
How to use expression(italic()) in a "vectorized" way (within a function)?
Dear expeRts, I would like to use expression() for creating labels in a splom, as shown in the first minimal example below. Is there any way I can simplify having to write "expression(italic(...))" several times? The second example is what I tried so far, but I can't manage to get italic() to work. Moreover, it still seems bulky... Cheers, Marius ## minimal example (working but
2010 Dec 22
3
How to integrate a function with additional argument being a vector or matrix?
Dear expeRts, I somehow don't see why the following does not work: integrand <- function(x, vec, mat, val) 1 # dummy return value A <- matrix(runif(16), ncol = 4) u <- c(0.4, 0.1, 0.2, 0.3) integrand(0.3, u, A, 4) integrate(integrand, lower = 0, upper = 1, vec = u, mat = A, val = 4) I would like to integrate a function ("integrand") which gets an "x" value (the
2011 Apr 18
4
splom, plotmath: how to add three lines of information with alignment?
Dear expeRts, I would like to create a scatter plot matrix with splom(). The lower panel should contain some additional information about the samples shown in the upper panel plot, see the splom() call below. Now two questions came up: (1) The lower panels show "tau" and "alpha" on top of each other. How can I plot *three* expressions on top of each other? I tried several
2010 Dec 21
1
How to suppress plotting for "xyplot(zoo(x))"?
Hi, I found the thread http://r.789695.n4.nabble.com/Matrix-as-input-to-xyplot-lattice-proper-extended-formula-syntax-td896948.html I used Gabor's approach and then tried to assign the plot to a variable (see below). But a Quartz device is opened... why? I don't want to have anything plot/printed, I just would like to store the plot object. Is there something like "plot =
2011 Apr 06
7
Quiz: Who finds the nicest form of X_1^\prime?
Dear expeRts, I would like to create a plotmath-label of the form X_1^\prime. Here is how to *not* do it [not nicely aligned symbols]: plot(0,0,main=expression(italic(X*minute[1]))) plot(0,0,main=expression(italic(X[1]*minute))) plot(0,0,main=expression(italic(X)[1]*minute)) Any suggestions? Cheers, Marius
2010 Dec 30
1
latex() etc.: How to nicely format a matrix for a LaTeX document?
Dear (T)eXpeRts, I try to create a LaTeX table from an R matrix for the first time. I am not sure what the "best" approach is, I just read about latex() from Hmisc (toLatex() didn't work). Consider the following minimal example: library(Hmisc) mat <- matrix(c(1,NA,3,100,10000,4), ncol = 3, byrow = TRUE) latex(mat, file = "", booktabs = TRUE, numeric.dollar = FALSE,
2011 Jun 02
1
[R-SIG-Mac] check leads to .o files and to packagename-Ex.R
On 06/02/2011 06:47 AM, Benilton Carvalho wrote: > 'R CMD check' should be applied on the .tar.gz, not on the source directory. Why? The help says: "Check R packages from package sources, which can be directories or package 'tar' archives with extension '.tar.gz', '.tar.bz2' or '.tgz'." I just skimmed through the relevant section (1.3.1) in
2011 Jun 02
2
lattice + plotmath: how to get a variable in bold face?
Dear all, How can I get a bold "1000" in the title? I would like to use a variable (as opposed to putting in "1000" directly). library(lattice) N <- 1000 xyplot(0~0, xlab.top=list(label=as.expression(bquote(bold("foo" ~ .(N) ~ "bar"))), font=2, cex=1.2)) ## => "font=2" is ignored (of course) Cheers, Marius
2010 Jun 23
1
how to print a colored plot in black/white?
Dear expeRts, shouldn't this... x <- 1:10 myplot <- xyplot(x~x,col="red") trellis.device(postscript,color=FALSE,file="plot.ps") print(myplot) dev.off() ... give a black/white plot? Cheers, Marius
2008 Jan 01
2
Alignment and Labeling of a color key in a xyplot?
Happy New Year to all R users! I have two short questions concerning a xyplot with a color key: 1) How do I properly place (align) the color key beside the xyplot? As you can see from the code listed below, the placement of the color key is not correct. I would like the upper and lower end point of the color key to be perfectly aligned with the upper and lower line of the xyplot. Adjusting
2011 Jun 21
2
Tricky (?) conversion from data.frame to matrix where not all pairs exist
Dear expeRts, In the minimal example below, I have a data.frame containing three "blocks" of years (the years are subsets of 2000 to 2002). For each year and block a certain "value" is given. I would like to create a matrix that has row names given by all years ("2000", "2001", "2002"), and column names given by all blocks ("a",
2011 Jun 02
2
plotmath: paste string and expression [from a vector of expressions]
Dear all, I have a vector of expressions and would like to "paste" some string to it before using it in a plot: vars <- vector("expression", 2) vars[1] <- expression(alpha) vars[2] <- expression(beta) plot(0, 0, main=substitute(bold("Foo" ~~ VAR), list(VAR=vars[2]) )) Although I tried hard, I just can't figure out how to solve this. The title should be
2011 May 11
1
foreach(): how to do calculations "between" two foreach loops?
Dear expeRts, is it possible to carry out calculations between different foreach() calls? As for nested loops, you want to carry out calcuations not depending on the inner loop only once and not for each iteration of the innermost loop. Cheers, Marius library(foreach) foreach(i=1:3) %:% foreach(j=1:2) %do% { i <- i+1 print(paste(i,j)) } foreach(i=1:3) %:% i
2006 May 29
3
mtext in trellis-loop & colorkey
Hello, I would like to create a sequence of plots (using a for loop). I read in the FAQ that print() has to be used in order to obtain any output. This works perfectly fine as long as I only consider one function call in the loop, but I would like to add mtext() to the each plot in the loop. Unfortunately, this did not work. Any suggestions? As you can see from the provided example,
2006 Feb 12
1
contour lines for levelplot
Hi, I would like to add contour lines to a (trellis/lattice-) levelplot. Sure, there is the "contour=TRUE" argument, but this uses "cuts=..." (which is usually chosen very high for my plots. I guess cuts=99 is the best you can do (?)) for plotting the contour lines. Furthermore, I do not like the numbering of the contour lines this way. Therefore, I tried to add a
2006 Mar 04
1
Controlling (number of) wires in wireframe
Hi, I would like to plot a wireframe (library: lattice) of the function f (x,y)=x*y where x and y are equally evaluated between 0 and 1. When one uses the option drape=TRUE then each "square" between the "wires" (lines that build the surface shape) gets a certain color. A perfect wireframe plot of a continuous surface would be, if you (almost) can not distinguish
2012 Dec 08
5
How to efficiently compare each row in a matrix with each row in another matrix?
Dear expeRts, I have two matrices A and B. They have the same number of columns but possibly different number of rows. I would like to compare each row of A with each row of B and check whether all entries in a row of A are less than or equal to all entries in a row of B. Here is a minimal working example: A <- rbind(matrix(1:4, ncol=2, byrow=TRUE), c(6, 2)) # (3, 2) matrix B <-
2010 Dec 26
1
lattice splom: how to adjust space between tick marks and tick labels?
Dear expeRts, how can I decrease the space between the tick marks and the corresponding labels in an splom? See here: library(lattice) U <- matrix(runif(4000), ncol = 8) splom(U, axis.text.cex = 0.2) # => space between the [small] tick labels and tick marks is/seems to be too large I checked ?panel.pairs but could not find an option for that. Cheers, Marius