[R] What's box() (exactly) doing?

2016-06-23 Thread Marius Hofert
Hi, I would like to replicate the behavior of box() with rect() (don't ask why). However, my rect()angles are always too small. I looked a bit into the internal C_box but couldn't figure out how to solve the problem. Below is a minimal working (and a slightly bigger) example. Cheers, Marius ## M

Re: [R] What's box() (exactly) doing?

2016-06-24 Thread Marius Hofert
gt; Finally your second example simply multiplies the first problem by > specifying a layout of more than one plot. Applying the "xaxs" and > "yaxs" parameters before you start plotting will fix this: > > par(xaxs="i",yaxs="i") > > Jim > &g

Re: [R] What's box() (exactly) doing?

2016-06-24 Thread Marius Hofert
col = adjustcolor("grey80", alpha.f = 0.5)) par(xpd = FALSE) On Fri, Jun 24, 2016 at 8:40 PM, Marius Hofert wrote: > Hi Jim, > > Thanks a lot, exactly what I was looking for. > > Cheers, > Marius > > > > On Thu, Jun 23, 2016 at 11:06 PM, Jim Lemon wrote: >

Re: [R] What's box() (exactly) doing?

2016-06-27 Thread Marius Hofert
On Mon, Jun 27, 2016 at 5:42 PM, Greg Snow <538...@gmail.com> wrote: > You can use the grconvertX and grconvertY functions to find the > coordinates (in user coordinates to pass to rect) of the figure region > (or other regions). > > Probably something like: > grconvertX(c(0,1), from='nfc', to='use

[R] How to split a data.frame into its columns?

2016-08-28 Thread Marius Hofert
Hi, I need a fast way to split a data.frame (and matrix) into a list of columns. For matrices, split(x, col(x)) works (which can then be done in C for speed-up, if necessary), but for a data.frame? split(iris, col(iris)) does not work as expected (?). The outcome should be lapply(seq_len(ncol(iris

Re: [R] How to split a data.frame into its columns?

2016-08-29 Thread Marius Hofert
Hi David and Jeff, Thanks for your quick help, unclass() was precisely what I was looking for. Cheers, M On Mon, Aug 29, 2016 at 10:39 AM, aditya pant wrote: > > ^^ठश्रएइ),,, > > From: David Winsemius > Sent: ‎29-‎08-‎2016 11:59 > To: Marius H

[R] How to test existence of an environment and how to remove it (from within functions)?

2016-08-29 Thread Marius Hofert
Hi, I have a function main() which calls another function aux() many times. aux() mostly does the same operations based on an object and thus I would like it to compute and store this object for each call from main() only once. Below are two versions of a MWE. The first one computes the right res

Re: [R] How to test existence of an environment and how to remove it (from within functions)?

2016-08-29 Thread Marius Hofert
anks & cheers, Marius On Mon, Aug 29, 2016 at 7:59 PM, Duncan Murdoch wrote: > On 29/08/2016 1:36 PM, Marius Hofert wrote: >> Hi, >> >> I have a function main() which calls another function aux() many times. aux() >> mostly does the same operations based on an obje

Re: [R] How to test existence of an environment and how to remove it (from within functions)?

2016-08-30 Thread Marius Hofert
Hi Duncan, ... I don't have to know (I thought). The idea was to set up the environment only for a single object x. If it (= the environment (see MWE 2) *or* the object (see MWE 1)) exists, it's the right one. But I agree that it's 'cleaner' to work with a hash -- yet I first wanted to understand

[R] Is there a plotmath symbol \mapsto?

2014-12-11 Thread Marius Hofert
Hi, Is there a plotmath symbol like LaTeX's \mapsto? I need this comparably often, for example if you want to plot a two-place function in one variable (and thus would like to have ylab="t \mapsto f(t,s)", for example). If there is such a symbol, I'd be great to have it as an example on ?plotmath.

Re: [R] Is there a plotmath symbol \mapsto?

2014-12-12 Thread Marius Hofert
Dear Professor Ripley, Thank you for your reply. Do you specify \u21A6 via something like this? plot(1, main=expression(symbol("\u21A6"))) This gives an the 'registered trademark symbol' (circled R) for me (also cairo-based Linux). Thanks and cheers, Marius ___

[R] How to convert a C vector to an SEXP for using it in R_orderVector()?

2015-03-01 Thread Marius Hofert
Hi, Inside a C function (foo()), I need to call R's order(). Writing R Extensions (2014, Section 6.10) gave me the hint to use R_orderVector() for this task. The third argument of this function needs an SEXP containing (in my case) the vector x (of which I would like to determine order()). My que

[R] Where to find source of C_pbinom?

2014-08-26 Thread Marius Hofert
Dear expeRts, I would like to find out how R computes pbinom(). A grep in the source code reveiled src/library/stats/R/distn.R:146: .External(C_pbinom, q, size, prob, lower.tail, log.p), so 'C_pbinom' refers to compiled C/C++ code loaded into R. Where can I find the source code of C_pbinom? Cheer

Re: [R] Where to find source of C_pbinom?

2014-08-27 Thread Marius Hofert
4 at 7:28 AM, Sarah Goslee wrote: > R FAQ 7.40 > > http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-access-the-source-code-for-a-function_003f > > Sarah > > > On Tuesday, August 26, 2014, Marius Hofert > wrote: >> >> Dear expeRts, >> >> I w

Re: [R] Where to find source of C_pbinom?

2014-08-27 Thread Marius Hofert
Dear Ranjan, thanks, that was what I was looking for. Somehow my 'grep' must have missed that. Cheers, Marius On Wed, Aug 27, 2014 at 8:34 AM, Marius Hofert wrote: > Dear Sarah, Dear David, > > thanks for helping. I know the FAQ and I know the R News article, but > I st

[R] dev.copy(postscript,...) generates a disrupted string

2009-10-24 Thread Marius Hofert
Dear R-Users, I have the following problem: I would like to create a postscript file containing an r-plot with the string "\\vartheta" in it (reason: this is later converted to the TeX-string "\vartheta" and a vartheta is printed in the figure). In the minimal example below, the problem is

[R] How to put text outside an xyplot?

2009-12-20 Thread Marius Hofert
Dear R-users, I have a plot created with the code below. I tried to put some text to the right of the color key. I worked with grid.text and also viewport(), but couldn't achieve this. I know this should be simple, but I just couldn't figure out how to do it. How does this work? Cheers, Mariu

[R] How to color a splom?

2010-01-14 Thread Marius Hofert
Dear R-Users, I would like to color the data in a splom according to their position in the matrix, i.e. I would like to have all data shown in the upper left corner to be blue, all entries below that to be black, and the data to the right to be all red. I tried to color the "splom" with the fol

[R] Lattice: How to color the data points in splom() according to the panel they are plotted?

2010-01-15 Thread Marius Hofert
Dear ExpeRts, I have the scatter plot matrix as given below. I would like the different "sub-plots" in the scatter plot matrix to be colored differently. How do I get all points shown in the upper-left plot (on position (1,1) in the scatter plot matrix) to be plotted in blue, and the points sho

[R] Why does the print method fail for very small numbers?

2022-02-17 Thread Marius Hofert
Dear expeRts, I'm familiar with IEEE 754. Is there an easy way to explain why even just printing of small numbers fails? 1e-317 # 1e-317 => fine 1e-318 # 9.87e-319 => gets tricky; seems to call print() => as.character() => format() => paste() 1e-318 == 9.87e-319 # TRUE 2.48e-324 # prints

[R] How to create the/an integer 'seed' for set.seed() from a given .Random.seed?

2019-07-20 Thread Marius Hofert
Hi, 1) Given .Random.seed, how can one compute *the* integer 'seed' such that set.seed(seed) generates .Random.seed? 2) If 1) is not possible, how can one compute *an* integer 'seed' from a given .Random.seed such that different .Random.seed's are guaranteed to give different integers 'seed' (or a

[R] R_BATCH_OPTIONS not respected?

2019-09-09 Thread Marius Hofert
Hi, I typically start R with "--no-restore --no-save" (to avoid .RData files being written) and would like to have the same behavior under 'R CMD BATCH'. I use R_BATCH_OPTIONS="--no-restore --no-save" in my ~/.Renviron but running an R script with 'R CMD BATCH' still produces a .RData file. What's

Re: [R] R_BATCH_OPTIONS not respected?

2019-09-10 Thread Marius Hofert
On Tue, Sep 10, 2019 at 12:38 PM Martin Maechler wrote: > > >>>>> Marius Hofert > >>>>> on Mon, 9 Sep 2019 22:38:38 +0200 writes: > > > Hi, > > I typically start R with "--no-restore --no-save" (to avoid .RData >

Re: [R] double.xmin really the smallest non-zero normalized floating-point number?

2013-09-10 Thread Marius Hofert
exp(-x) being not quite 0, but x=746 leads to exp(-x)==0 being TRUE. But these are integer x's... Many thanks and cheers, Marius > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > >> -Original Message----- >> From: r-help-boun...@r-project.or

[R] double.xmin really the smallest non-zero normalized floating-point number?

2013-09-10 Thread Marius Hofert
Hi, ?.Machine says that 'double.xmin' is 'the smallest non-zero normalized floating-point number'. On my machine, this is 2.225074e-308. However, 2.225074e-308 / 2 is > 0 and smaller than 2.225074e-308, so double.xmin is not the smallest such number (?) Am I missing anything? Cheers, Marius ___

[R] tables package: How to remove column headings and alignment issues

2013-01-18 Thread Marius Hofert
Dear expeRts, Here is a minimal example with the latest version of 'tables' (questions below): require(tables) saveopts <- table_options(toprule="\\toprule", midrule="\\midrule", bottomrule="\\bottomrule", titlerule="\\cmidrule(lr)", rowlabeljustification="r")#, justi

[R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-22 Thread Marius Hofert
Dear expeRts, I struggle with the following problem using snow clusters for parallel computing: I would like to specify l'Ecuyer's random number generator. Base R creates a .Random.seed of length 7, the first value indicating the kind fo random number generator. I would thus like to use the com

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-22 Thread Marius Hofert
;> library(snow) >> RNGkind("L'Ecuyer-CMRG") >> cl <- makeCluster(parallel::detectCores(), type="MPI") > 4 slaves are spawned successfully. 0 failed. >> .t <- snow::clusterSetupRNG(cl, seed=.Random.seed[2:7]) >> stopCluster(cl) > >

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-22 Thread Marius Hofert
I updated to the latest CRAN versions of 'rlecuyer', 'Rmpi', and 'snow': ,[ sessionInfo() ] | ... | other attached packages: | [1] rlecuyer_0.3-3 Rmpi_0.6-1 snow_0.3-10 | ... ` But I still obtain: , | Error in .lec.SetPackageSeed(seed) : | Seed[1] >= -1065242851, Seed i

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-23 Thread Marius Hofert
Since clusterSetupRNG() calls clusterSetupRNGstream() and this calls .lec.SetPackageSeed(), I could further minimalize the problem: set.seed(1) RNGkind("L'Ecuyer-CMRG") # => .Random.seed is of length 7 (first number encodes the rng kind) (seed <- .Random.seed[2:7]) # should give a valid seed for

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-23 Thread Marius Hofert
Dear Hana, Thanks for helping. I am still wondering, why m1 (which should be 2^32-209 [see line 34 in ./src/RngStream.c]) is -767742437 in my case and why the minimal example you gave was working for you but isn't for me. Apart from that, ?.Random.seed -> "L'Ecuyer-CMRG" says: , | The 6 ele

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-23 Thread Marius Hofert
Dear Daniel, That's exactly what I also suspected (last post). The question now seems how to correctly convert .Random.seed from signed to unsigned so that it is accepted by the rlecuyer package. Cheers, Marius __ R-help@r-project.org mailing list ht

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-24 Thread Marius Hofert
Thanks a lot, Duncan, that solved it! Cheers, Marius Duncan Murdoch writes: > On 13-01-24 2:09 AM, Marius Hofert wrote: >> Dear Daniel, >> >> That's exactly what I also suspected (last post). The question now seems how >> to >> correctly convert .Rando

[R] How to 'extend' a data.frame based on given variable combinations ?

2013-03-11 Thread Marius Hofert
Dear expeRts, I have a data.frame with certain covariate combinations ('group' and 'year') and corresponding values: set.seed(1) x <- data.frame(group = c(rep("A", 4), rep("B", 3)), year = c(2001, 2003, 2004, 2005, 2003, 2004, 2005),

Re: [R] How to 'extend' a data.frame based on given variable combinations ?

2013-03-11 Thread Marius Hofert
tply, by=c("group", "year"), all=TRUE) # merge the two data.frames tply$num[is.na(tply$num)] <- 0 tply Marius Hofert <> writes: > Dear expeRts, > > I have a data.frame with certain covariate combinations ('group' and 'year') >

[R] aggregate(), tapply(): Why is the order of the grouping variables not kept?

2013-03-11 Thread Marius Hofert
Dear expeRts, The question is rather simple: Why does aggregate (or similarly tapply()) not keep the order of the grouping variable(s)? Here is an example: x <- data.frame(group = rep(LETTERS[1:2], each=10), year = rep(rep(2001:2005, each=2), 2), value = rep(1:1

Re: [R] aggregate(), tapply(): Why is the order of the grouping variables not kept?

2013-03-12 Thread Marius Hofert
> > I'm no expeRt, but suppose that we change the setup slightly: > > xx <- x[sample(nrow(x)), ] > > Now what would you like > > aggregate(value ~ group + year, data=xx, FUN=function(z) z[1]) > > to return? > > Personally, I prefer to have R return the same thing regardless > of how the input da

[R] How to construct a 'proper' Q-Q line in log-log space?

2013-06-29 Thread Marius Hofert
Dear expeRts, I would like to create a Q-Q plot including a Q-Q line for Gamma distributed data. The specialty is that it should be in log-log scale. For Q-Q line in log-log scale, I discovered the argument 'untf' of abline. As you can see in 2), this works fine. But for 3) it does not provide the

[R] How to convert the output of tapply() so that it has the same order as the input?

2012-09-15 Thread Marius Hofert
Hi, I try to apply a function to subsets of a data.frame. tapply() does the job, but the as output, I am looking for a vector (not an array/matrix) ordered in the same way as the original data, so I can simply cbind the result to the original data.frame. Below is a minimal example. I know that th

Re: [R] How to convert the output of tapply() so that it has the same order as the input?

2012-09-15 Thread Marius Hofert
Dear Bill, Thanks a lot for your quick reply, that was exactly what I was looking for. Cheers, Marius William Dunlap writes: > Does ave() do what you want? > y. <- ave(x$value, x$x1, x$x2, FUN=function(x)x) > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > >

[R] How to determine R version?

2012-09-22 Thread Marius Hofert
Hi, What's the best approach to determine if a user uses an R version before 2.15.1 patched? I know that the sessionInfo() command provides details, but I'm not sure how the output of sessionInfo() is best used to determine R versions. This seems to work, but a) there is certainly a better way and

Re: [R] How to determine R version?

2012-09-22 Thread Marius Hofert
Thanks, Berend, that works. Cheers, Marius Berend Hasselman writes: > On 22-09-2012, at 19:32, Marius Hofert wrote: > >> Hi, >> >> What's the best approach to determine if a user uses an R version before >> 2.15.1 >> patched? >> I know that

[R] grid: How to merge cells in grid.layout?

2012-09-23 Thread Marius Hofert
Dear grid expeRts, I would like to create a layout with grid that looks like the following, but with cells (1,1), (1,4), (4,1), and (4,4) removed and cells (2,1) and (3,1) (and (4,2) and (4,3)) combined to one cell (so that contents can easily be centered. How can this be achieved? requir

Re: [R] grid: How to merge cells in grid.layout?

2012-09-23 Thread Marius Hofert
Bert Gunter writes: > Inline below. > > On Sun, Sep 23, 2012 at 1:41 AM, Marius Hofert > wrote: >> Dear grid expeRts, >> >> I would like to create a layout with grid that looks like the following, but >> with cells (1,1), (1,4), (4,1), and (4,4) removed and

Re: [R] grid: How to merge cells in grid.layout?

2012-09-23 Thread Marius Hofert
Ahh, now I see what you mean... Thanks, that indeed works. Cheers, Marius Marius Hofert writes: > Bert Gunter writes: > >> Inline below. >> >> On Sun, Sep 23, 2012 at 1:41 AM, Marius Hofert >> wrote: >>> Dear grid expeRts, >>> >>>

[R] Background color in a grid plot seems to interfere with plot()

2012-09-23 Thread Marius Hofert
Hi, Why does the upper left panel (in the plot below) not have a gray background? Cheers, Marius require(grid) require(gridBase) pdf(file="Rplot.pdf", width=8, height=8, onefile=FALSE) ## set up the grid layout gl <- grid.layout(5, 5, widths=unit(c(1.8, 8, 0.8, 8, 0.8), "cm"),

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-23 Thread Marius Hofert
par(plt=gridPLT()) ## plot par(new=TRUE) # always do this before each new 'graphics' plot grid(col=1) plot(1:10, 1:10, log="y", xlab="", ylab="", xaxt=if(i==2) "s" else "n", yaxt=if(j==1) &q

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-23 Thread Marius Hofert
Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > Marius Hofert wrote: > >>Dear Paul, >> >>Thank you for helping. T

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-24 Thread Marius Hofert
frame.plot=FALSE, xaxt="n", yaxt="n") grid(col="white", lty="solid", lwd=1.6, equilogs=FALSE) # background grid upViewport() } } par(par.) dev.off() Paul Murrell writes: > Hi > > On 24/09/12 18:06, Marius Hofert wrote:

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-24 Thread Marius Hofert
="n", yaxt="n") grid(col="white", lty="solid", lwd=1.6, equilogs=FALSE) # background grid upViewport() } } par(par.) dev.off() Paul Murrell writes: > Hi > > On 25/09/12 11:50, Marius Hofert wrote: >> Dear Paul, >> >

Re: [R] Background color in a grid plot seems to interfere with plot()

2012-09-26 Thread Marius Hofert
Dear Paul, Many thanks, that solved it. Cheers, Marius Paul Murrell writes: > Hi > > On 25/09/2012 6:10 p.m., Marius Hofert wrote: >> Dear Paul, >> >> Thanks. Redrawing the points solves it for the minimal example, but >> what happens if you have plot(..,

[R] grid(Base): How to avoid "Figure region too small and/or viewport too large" by specifying 'relative' units?

2012-10-19 Thread Marius Hofert
Dear grid-expeRts, The goal: I would like to construct a plot (matrix) with grid and gridBase, which consists of four "sub-plots". The sub-plots should have a square plotting region as one would force with par(pty="s") in base graphics. The problem: I don't get a square plotting region, not eve

Re: [R] grid(Base): How to avoid "Figure region too small and/or viewport too large" by specifying 'relative' units?

2012-10-19 Thread Marius Hofert
In the meanwhile, I found a more minimal example which shows the problem (just change 'inch' to TRUE to see the difference): require(grid) inch <- FALSE # TRUE d <- if(inch) 5 else 1 pspc <- d*c(0.3, 0.3) # width, height of panels spc <- d*c(0.05, 0.05) # width, height of space axlabspc <- d*c(

Re: [R] quantile regression using copulas

2012-10-21 Thread Marius Hofert
Please note: 1) your example is not working in the way you provided it (see http://www.minimalbeispiel.de/mini-en.html) 2) you receive a warning, not an error 3) I'd try and debug qua.regressCOP2 to see why the warning appears 4) in case 3) does not help, contact the maintainer of copBasic (Willia

Re: [R] grid(Base): How to avoid "Figure region too small and/or viewport too large" by specifying 'relative' units?

2012-10-22 Thread Marius Hofert
ith the diagram. > If you change your grid.show.layout() call to the following (which "removes" > the > normal margin used by grid.show.layout()) ... > > grid.show.layout(gl, vp=viewport(width=1.25, height=1.25)) > > ... then you should find your viewports line up with

[R] sort() depends on locale

2014-06-14 Thread Marius Hofert
Hi, If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then > sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "L.Y" "Lu" whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results in > sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "Lu" "L.Y" I know this issue has appeared alr

Re: [R] sort() depends on locale (and platform and build)

2014-06-15 Thread Marius Hofert
Hi, Thanks for you help. I use R-devel under Ubuntu 14.04, here is the output of sessionInfo(): > sessionInfo() R Under development (unstable) (2014-06-02 r65832) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_C

Re: [R] sort() depends on locale (and platform and build)

2014-06-15 Thread Marius Hofert
Hi, ... so something like this? [in foo.R] old.coll <- Sys.getlocale("LC_COLLATE") Sys.setlocale("LC_COLLATE", locale="C") Sys.setlocale("LC_COLLATE", locale=old.coll) Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

[R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Marius Hofert
Dear expeRts, What's a 'good' (nice-looking, easy-to-read) setup for the LaTeX package 'listings' to display R code? The two versions below are partly inspired by the settings of the package SweaveListingUtils and http://r.789695.n4.nabble.com/R-How-to-format-R-code-in-LaTex-documents-td816055.ht

Re: [R] How to nicely display R code with the LaTeX package 'listings'?

2012-11-01 Thread Marius Hofert
ell > wrote: >> The knitr package makes this relatively easy to do. See for example >> http://biostat.mc.vanderbilt.edu/KnitrHowto >> >> Frank >> >> >> Marius Hofert-3 wrote >>> Dear expeRts, >>> >>> What's a 'good&#x

[R] \lstdefinelanguage error: undefined control sequence

2012-11-02 Thread Marius Hofert
Dear expeRts, I'm trying to use the package SweaveListingUtils, but the rather minimal example below leads to , | ./minimal.tex:43: Undefined control sequence. | l.43 \lstdefinelanguage |{Rd}[common]{TeX}% | ? ` Why? Cheers, Marius \documentclass[article]{jss}

[R] Constant (= wrong) historical quotes via get.hist.quote() from yahoo.finance

2012-11-22 Thread Marius Hofert
Dear expeRts, I would like to download a time series of historical data from the ticker with symbol "ROG.VX". Interestingly, I obtain constant values (138.3 for each day in the chosen period) although the yahoo.finance website tells me that the time series is not at all constant. What's wrong?

Re: [R] Constant (= wrong) historical quotes via get.hist.quote() from yahoo.finance

2012-11-23 Thread Marius Hofert
gt; On Fri, 23 Nov 2012, Marius Hofert wrote: > >> Dear expeRts, >> >> I would like to download a time series of historical data from the ticker >> with >> symbol "ROG.VX". Interestingly, I obtain constant values (138.3 for each day >> in the chosen p

[R] How to efficiently compare each row in a matrix with each row in another matrix?

2012-12-08 Thread Marius Hofert
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 work

[R] (gam) formula: Why different results for terms being factor vs. numeric?

2013-10-29 Thread Marius Hofert
Dear expeRts, If I specify group = as.factor(rep(1:2, each=n)) in the below definition of dat, I get the expected behavior I am looking for. I wonder why I don't get it if group is *not* a factor... My guess was that, internally, factors are treated as natural numbers (and this indeed seems to be

Re: [R] (gam) formula: Why different results for terms being factor vs. numeric?

2013-11-02 Thread Marius Hofert
Dear Bert, Thanks for helping. Your questions 'answers' why I get the expected behavior if 'group' is a factor. My question was why I don't get the expected behavior if 'group' is not a factor. >From a theoretical (non-programming) point of view, there is no difference in a factor with two level

[R] how to print a colored plot in black/white?

2010-06-23 Thread Marius Hofert
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 __ R-help@r-project.org mailing list https://stat.eth

[R] How to set an argument such that a function treats it as missing?

2010-11-13 Thread Marius Hofert
Dear expeRts, I would like to call a function f from a function g with or without an argument. I use missing() to check if the argument is given. If it is not given, can I set it to anything such that the following function call (to f) behaves as if the argument isn't given? It's probably bes

Re: [R] How to set an argument such that a function treats it as missing?

2010-11-13 Thread Marius Hofert
Ahh, thank you very much, precisely what I was looking for :-))) Cheers, Marius On 2010-11-13, at 12:41 , Duncan Murdoch wrote: > Marius Hofert wrote: >> Dear expeRts, >> I would like to call a function f from a function g with or without an >> argument. I use miss

[R] How to use expression(italic()) in a "vectorized" way (within a function)?

2010-11-26 Thread Marius Hofert
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 w

[R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-26 Thread Marius Hofert
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@r-project.org/msg64699.html I use trellis.device() to set the colors to FALSE. Whenever I call the minimal example bel

Re: [R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-27 Thread Marius Hofert
ht thing which I would if I used the "col = 1" options in the call of xyplot Cheers, Marius On 2010-11-27, at 02:38 , David Winsemius wrote: > > On Nov 26, 2010, at 6:35 PM, Marius Hofert wrote: > >> Dear expeRts, >> >> I am not sure if I found a bug... >

Re: [R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-27 Thread Marius Hofert
plot.(U) b ... but it didn't work :-( Cheers, Marius On 2010-11-27, at 12:00 , ottorino wrote: > Il giorno sab, 27/11/2010 alle 00.35 +0100, Marius Hofert ha scritto: >> The reason why I would like to use trellis.device() within a function >> is that >> the plo

Re: [R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-27 Thread Marius Hofert
Thanks very much, exactly what I was looking for :-))) Cheers, Marius On 2010-11-27, at 13:16 , Peter Ehlers wrote: > On 2010-11-27 03:31, Marius Hofert wrote: >> Hi, >> >> I get a warning () using >> >> xyplot.<- function(u) { >> BW.theme<-

[R] lattice: remove box around wireframe (*follow-up*)

2010-11-27 Thread Marius Hofert
Dear expeRts, below is a minimal example from the thread http://www.mail-archive.com/r-help@r-project.org/msg48098.html about how to remove the outer box / frame of a wireframe plot. As one can see, the suggested code does remove the box (by making it transparent), however, it also removes the

[R] lattice: remove box around wireframe (*follow-up*)

2010-11-27 Thread Marius Hofert
okay, solved :-)) It is mentioned here: http://r.789695.n4.nabble.com/How-to-remove-outer-box-from-Wireframe-plots-td824819.html so ... wireframe(z ~ x*y, data = test, scales = list(col = "black", arrows = FALSE), par.settings = list(axis.line = list(col = "transparent"))) ... solves it. Cheer

Re: [R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-27 Thread Marius Hofert
col="transparent"), clip=list(panel="off"))) Cheers, Marius On 2010-11-27, at 13:16 , Peter Ehlers wrote: > On 2010-11-27 03:31, Marius Hofert wrote: >> Hi, >> >> I get a warning () using >> >> xyplot.<- function(u) {

Re: [R] lattice: strange behavior (?) when using trellis.device(color=FALSE)

2010-11-27 Thread Marius Hofert
Dear Peter, thanks a lot, modifyList() did it perfectly! Cheers, Marius On 2010-11-28, at 01:26 , Peter Ehlers wrote: > On 2010-11-27 15:03, Marius Hofert wrote: >> Dear Peter, >> >> do you know anything similar for a cloud() plot? >> This does not work: &

[R] How to catch both warnings and errors?

2010-12-05 Thread Marius Hofert
Dear expeRts, I am struggling with warning/error handling. I would like to call a function which can produce either a) normal output b) a warning c) an error Since the function is called several (thousand) times in a loop, I would like to proceed "quietly" and collect the warnings and errors

Re: [R] How to catch both warnings and errors?

2010-12-05 Thread Marius Hofert
On 2010-12-06, at 01:07 , David Winsemius wrote: > > On Dec 5, 2010, at 3:13 PM, Marius Hofert wrote: > >> Dear expeRts, >> >> I am struggling with warning/error handling. >> >> I would like to call a function which can produce either >> a)

Re: [R] How to catch both warnings and errors?

2010-12-06 Thread Marius Hofert
Hmm... still not quite what I was hoping for... but thanks anyway. I would like to have the output in the following form: > f(1) $result [1] 0 $warning [1] NULL # or "" $error [1] NULL # or "" > f(-1) $result [1] NaN $warning [1] "Warning in log(-1) : NaNs produced" # or something similar $

Re: [R] [R-sig-hpc] Error in makeMPIcluster(spec, ...): how to get a minimal example for parallel computing with doSNOW to run?

2010-12-16 Thread Marius Hofert
Dear Mario, I tried "-n 4" and obtain the same error :-( Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commente

[R] How to suppress plotting for "xyplot(zoo(x))"?

2010-12-21 Thread Marius Hofert
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/pri

[R] How to integrate a function with additional argument being a vector or matrix?

2010-12-22 Thread Marius Hofert
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

Re: [R] How to integrate a function with additional argument being a vector or matrix?

2010-12-22 Thread Marius Hofert
Ahh... thanks, I totally missed that. Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-con

[R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
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 ?

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
what I am looking for. Cheers, Marius On 2010-12-26, at 14:36 , David Winsemius wrote: > > On Dec 26, 2010, at 5:41 AM, Marius Hofert wrote: > >> Dear expeRts, >> >> how can I decrease the space between the tick marks and the corresponding >> labels in

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
Dear Peter, thank you very much, *precisely* what I was looking for! Cheers, Marius On 2010-12-27, at 02:27 , Peter Ehlers wrote: > On 2010-12-26 08:26, Marius Hofert wrote: >> Dear David, >> >> thank you for your answer. >> As I wrote, I am looking for an o

[R] foreach + dopar: how to check progress of parallel computations?

2010-12-28 Thread Marius Hofert
Dear expeRts, I use foreach to do parallel computations. Is it possible to have some progress output written while the computations are done? In the minimal example below, I just print a number ("n") to check the progress. If you run this example with "%do%" instead of "%dopar%", then the compu

[R] How to create an array of lists of multiple components?

2010-12-29 Thread Marius Hofert
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,

Re: [R] How to create an array of lists of multiple components?

2010-12-29 Thread Marius Hofert
L)), n1*n2*n3), dim = c(n1,n2,n3)) >> res[1,1,1] # is not a list with three components... > [[1]] > [[1]][[1]] > NULL > > [[1]][[2]] > NULL > > [[1]][[3]] > NULL > > >> str(res) > List of 40 > $ :List of 3 > ..$ : NULL > ..$ : NULL &g

Re: [R] How to create an array of lists of multiple components?

2010-12-30 Thread Marius Hofert
Dear Gabor, *perfect*, precisely what I was looking for. Many thanks, Marius On 2010-12-29, at 23:19 , Gabor Grothendieck wrote: > On Wed, Dec 29, 2010 at 4:58 PM, Marius Hofert wrote: >> Dear Jim, >> >> thanks for your quick response. Here is what I try to ac

[R] latex() etc.: How to nicely format a matrix for a LaTeX document?

2010-12-30 Thread Marius Hofert
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,1,4), ncol = 3, byr

[R] Why is format(10000, big.mark = "\\,") not 10\,000?

2010-12-30 Thread Marius Hofert
Hi, why does format(1, big.mark = "\\,") not give me "10\,000"? How can I get this kind of "big.mark"? Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-p

Re: [R] Why is format(10000, big.mark = "\\,") not 10\,000?

2010-12-30 Thread Marius Hofert
to have "10\,000" is for use in LaTeX. If I produce the format "10\\,000" in a table, then xtable gives me 10$\backslash$,000 for the corresponding cell entry, which is wrong :-(. Do you know a trick for that? Cheers, Marius > > > Uwe Ligges > > > >

Re: [R] Why is format(10000, big.mark = "\\,") not 10\,000?

2010-12-30 Thread Marius Hofert
Ahhh, great! I knew it will be correct if the output is directed to a file, but I wanted it for the console [which is perfectly solved by cat()]. Thanks, Uwe. Cheers, Marius On 2010-12-30, at 19:55 , Uwe Ligges wrote: > > > On 30.12.2010 19:53, Marius Hofert wrote: &g

Re: [R] latex() etc.: How to nicely format a matrix for a LaTeX document?

2010-12-30 Thread Marius Hofert
us On 2010-12-30, at 21:29 , John Kane wrote: > Have a look at xtable. > > --- On Thu, 12/30/10, Marius Hofert wrote: > >> From: Marius Hofert >> Subject: [R] latex() etc.: How to nicely format a matrix for a LaTeX >> document? >> To: "Help R" >&g

[R] lattice: how to "center" a title?

2011-01-04 Thread Marius Hofert
Dear expeRts, As you can see from this example... trellis.device("pdf", width = 5, height = 5) print(xyplot(0 ~ 0, main = "This title is not 'centered' for the human's eye", scales = list(alternating = c(1,1), tck = c(1,0 dev.off() ... the title does not seem to be "centered" for the huma

[R] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread Marius Hofert
Dear expeRts, I usually use par.settings = standard.theme(color = FALSE) to create lattice graphics without colors, so something like library(lattice) x <- runif(10) xyplot(x ~ 1:10, type = "l", par.settings = standard.theme(color = FALSE)) Now I would like to use an additional component in par

Re: [R] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread Marius Hofert
Dear David, this I already tried. But as you can see, the plot itself *is* colored. However, I want to have color = FALSE, so, unfortunately, this approach does not work... Cheers, Marius On 2011-01-04, at 14:32 , David Winsemius wrote: > > On Jan 4, 2011, at 5:57 AM, Marius Hofert

  1   2   3   >