[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 #

[ESS] Emacs can find R-devel and R-newest, but not R-4.0.x

2020-11-25 Thread Marius Hofert via ESS-help
Hi, I used to be able to start a specific R version with M-x R-... but it doesn't work anymore. On M-x R- I see: R-devel R-initialize-on-start R-mode R-newest R-transcript-mode ... but no R-4.0.x. I have R-4.0.0, R-4.0.2, R-4.0.3 and R-devel installed and M-x R-devel and M-x R-newest correctly

[ESS] error in process sentinel: Not enough arguments for format string

2019-12-11 Thread Marius Hofert via ESS-help
Hi, As I reported on https://github.com/emacs-ess/ESS/issues/883 (last post), I'm (still) affected by the randomly appearing error "error in process sentinel: Not enough arguments for format string" and related 'freezing' of Emacs (which is especially popular when teaching in front of 300

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 >

[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.

[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

[ESS] in 18.10.3: Roxygen header is put at the wrong place if point is at the beginning of the line

2019-06-08 Thread Marius Hofert via ESS-help
Hi, I realized that in the current snapshot version of ESS (18.10.3), C-c C-o C-o (for Roxygen function headers) does not work as expected anymore (on macOS 10.14.5) in the following case (and others): fun1 <- function(x) x fun2 <- function(x) x If the point is right before the "f" (so column

[ESS] Assignment operator "<-" not bound to "_" anymore (or any other default it seems).

2019-03-26 Thread Marius Hofert via ESS-help
r "<-" seems weird to me and not everyone likes to make adjustments to .emacs just to get basic functionality (... and thus probably switches to RStudio...). Cheers, Marius -- Marius Hofert, Dr. rer. nat. Assistant Professor Department of Statistics and Actuarial Science Faculty

Re: [ESS] Indent for R's 'switch'

2018-06-22 Thread Marius Hofert via ESS-help
> On Fri 22 Jun 2018 at 09:50, Marius Hofert via ESS-help > wrote: > > > Hi, > > > > ESS (version 16.10-1 but also earlier) gives the following indentation > > for switch statements in r: > > > > f <- function(method = c("foo", "bar"))

[ESS] Indent for R's 'switch'

2018-06-22 Thread Marius Hofert via ESS-help
Hi, ESS (version 16.10-1 but also earlier) gives the following indentation for switch statements in r: f <- function(method = c("foo", "bar")) { switch(match.arg(method), "foo" = { # (*) cat("Will use 'method' = \"foo\".\n") }, "bar" = { cat("Will use

[ESS] Strange behaviour of ess-eval-buffer-from-beg-to-here?

2017-08-09 Thread Marius Hofert
Hi, Here is some R code, that, when put in an R script (.R), shows some strange behaviour (see sessionInfo() etc. below) under ess-version: 16.10-1. (foo <- matrix(rnorm(100), ncol = 5)) L <- matrix(c(2, 0, 0, 6, 1, 0, -8, 5, 3), ncol = 3, byrow = TRUE) Sigma <- L %*%

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

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

2016-08-29 Thread Marius Hofert
On Mon, Aug 29, 2016 at 7:59 PM, Duncan Murdoch <murdoch.dun...@gmail.com> 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

[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

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

2016-08-29 Thread Marius Hofert
: ‎29-‎08-‎2016 11:59 > To: Marius Hofert > Cc: R-help > Subject: Re: [R] How to split a data.frame into its columns? > > >> On Aug 28, 2016, at 11:14 PM, Marius Hofert <marius.hof...@uwaterloo.ca> >> wrote: >> >> Hi, >> >> I need a fast way t

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

2016-08-29 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

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',

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

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

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

2016-06-24 Thread Marius Hofert
t; par(xpd=FALSE) > > 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"

[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 ##

[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

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] 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] Where to find source of C_pbinom?

2014-08-27 Thread Marius Hofert
://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 marius.hof...@math.ethz.ch wrote: Dear expeRts, I would like to find out how R computes pbinom(). A grep in the source code reveiled src/library/stats/R

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 marius.hof...@math.ethz.ch wrote: Dear Sarah, Dear David, thanks for helping. I know the FAQ and I know the R News article, but I

[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?

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-8

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) do_your_sorting_here Sys.setlocale(LC_COLLATE, locale=old.coll) Cheers, Marius __ R-help@r-project.org mailing list

[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 already

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

[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

[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] 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

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 dataframe is

[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
$num)] - 0 tply Marius Hofert writes: 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

[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 =

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 .Random.seed from signed to unsigned so

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

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

[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

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

2013-01-22 Thread Marius Hofert
successfully. 0 failed. .t - snow::clusterSetupRNG(cl, seed=.Random.seed[2:7]) stopCluster(cl) Hana On 1/22/13 4:53 PM, Marius Hofert wrote: 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

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

[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)#,

[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

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

2012-11-23 Thread Marius Hofert
: 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 period) although the yahoo.finance website tells me

[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?

[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] 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

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

2012-11-01 Thread Marius Hofert
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' (nice-looking, easy-to-read) setup for the LaTeX package 'listings' to display R code? The two versions below are partly inspired

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
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 the diagram properly. Paul On 20/10/12 19:10, Marius Hofert

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

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

2012-10-20 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(0.1,

[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 even

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 p.murr...@auckland.ac.nz 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(.., type=b) like below

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

2012-09-25 Thread Marius Hofert
...@stat.auckland.ac.nz writes: Hi On 25/09/12 11:50, Marius Hofert wrote: Dear Paul, Thanks for helping. Is there a way to call grid() first? The problem seems to be that everything drawn before grid() is overplotted. No, but you can redraw the points ... require(grid) require(gridBase) pdf(file

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

2012-09-24 Thread Marius Hofert
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) s else n) upViewport() } } par(par.) dev.off() Paul Murrell p...@stat.auckland.ac.nz writes: Hi On 24/09/12 09:36, Marius Hofert wrote: Hi

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

2012-09-24 Thread Marius Hofert
Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Marius Hofert marius.hof...@math.ethz.ch wrote: Dear Paul, Thank you for helping. This works great. I then tried to put

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

2012-09-24 Thread Marius Hofert
() } } par(par.) dev.off() Paul Murrell p...@stat.auckland.ac.nz writes: Hi On 24/09/12 18:06, Marius Hofert wrote: Dear Paul, Thank you for helping. This works great. I then tried to put in a grid (via grid()). Why does that fail? Because grid() is used to add lines to an existing

[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?

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

2012-09-23 Thread Marius Hofert
Bert Gunter gunter.ber...@gene.com writes: Inline below. On Sun, Sep 23, 2012 at 1:41 AM, Marius Hofert marius.hof...@math.ethz.ch 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

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 marius.hof...@math.ethz.ch writes: Bert Gunter gunter.ber...@gene.com writes: Inline below. On Sun, Sep 23, 2012 at 1:41 AM, Marius Hofert marius.hof...@math.ethz.ch wrote: Dear grid expeRts, I

[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),

[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

Re: [R] How to determine R version?

2012-09-22 Thread Marius Hofert
Thanks, Berend, that works. Cheers, Marius Berend Hasselman b...@xs4all.nl 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 the sessionInfo() command provides details

[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

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 wdun...@tibco.com 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 insert vertical space between lines of tables created with the R package 'tables'?

2012-09-08 Thread Marius Hofert
I have the data frame... df - cbind(expand.grid(d=as.factor(c(2,5)), n=c(100, 200), beta=as.factor(c(0.2, 0.8)), group=LETTERS[1:2]), value=runif(16)) ... which I would like to display in a table like ... require(tables) tabular(d * beta ~ group * mean * Heading() * value, data=df) Now I would

Re: [R] How to insert vertical space between lines of tables created with the R package 'tables'?

2012-09-08 Thread Marius Hofert
Duncan Murdoch murdoch.dun...@gmail.com writes: The + means concatenation, so that spec says to put the RowFactor above the d*beta rows. Not sure why that causes an error, but it's likely because you've got the wrong number of items. This should work, but it doesn't give you the extra

Re: [R] patchDVI: how to pass encoding of the .Rnw file?

2012-08-24 Thread Marius Hofert
Dear Duncan, many thanks for helping. It works fine. Cheers, Marius Duncan Murdoch murdoch.dun...@gmail.com writes: On 12-08-19 3:47 PM, Marius Hofert wrote: Dear Duncan, I recently asked a question concerning patchDVI on r-help, see , | https://stat.ethz.ch/pipermail/r-help/2012

[R] How to call patchDVI::SweavePDF on an .Rnw which is not the master file?

2012-08-16 Thread Marius Hofert
Dear expeRts, I have a master file master.tex containing the preamble and which inputs (via \input{chapter01}, \input{chapter02}, ...) chapters. The chapters are .Rnw files. My goal is to use patchDVI::SweavePDF to compile the chapters (say, chapter.Rnw) individually (each chapter starts with

[R] Hmisc's latex: na.blank and grouping not working as expected

2012-05-02 Thread Marius Hofert
Dear expeRts, Why does na.blank=TRUE not replace the NA's in the following LaTeX table? x - matrix(1:72, ncol=4, nrow=8) colnames(x) - c(gr1.sgr1, gr1.sgr2, gr2.sgr1, gr2.sgr2) rn - apply(expand.grid(beta=c(0.25, 0.75), n=c(100, 500), d=c(10, 100))[, 3:1], 2, rmNames) x - cbind(rn, x) # append

Re: [R] Hmisc's latex: na.blank and grouping not working as expected

2012-05-02 Thread Marius Hofert
to avoid this. On 2012-05-02, at 09:26 , Marius Hofert wrote: Dear expeRts, Why does na.blank=TRUE not replace the NA's in the following LaTeX table? x - matrix(1:72, ncol=4, nrow=8) colnames(x) - c(gr1.sgr1, gr1.sgr2, gr2.sgr1, gr2.sgr2) rn - apply(expand.grid(beta=c(0.25, 0.75), n=c

Re: [R] How to colorize the panel backgrounds of pairs()?

2012-03-02 Thread Marius Hofert
(usr) rect(ll[1], ll[3], ll[2], ll[4], col=bg) points(x, y, cex=0.5) } mydiag.panel - function(x, ...){ ll - par(usr) rect(ll[1], ll[3], ll[2], ll[4], col=#FDFF65) } U - matrix(runif(4*500), ncol=4) pairs(U, panel=mypanel, diag.panel=mydiag.panel) Marius Hofert marius.hof

Re: [R] How to colorize the panel backgrounds of pairs()?

2012-03-02 Thread Marius Hofert
Okay, one simply has to use label.pos=0.5 in pairs() to get the correct behavior. On 2012-03-02, at 09:10 , Marius Hofert wrote: Dear Ilai, I tried to also adjust the diagonal panels. However, the variable names are not positioned correctly anymore. Do you know a solution? Cheers

[R] How to colorize the panel backgrounds of pairs()?

2012-03-01 Thread Marius Hofert
Dear expeRts, I would like to colorize the backgrounds of a pairs plot according to the respective panel number. Here is what I tried (without success): count - 0 mypanel - function(x, y, ...){ count - count+1 bg. - if(count %in% c(1,4,9,12)) #FDFF65 else NA points(x, y, cex=0.5,

[R] How to access the panel rows/columns in pairs()?

2012-01-21 Thread Marius Hofert
Hi, I would like to colorize certain panels in the pairs plot below with certain colors. How can access the panel row and column in a pairs plot to achieve this? Cheers, Marius ## generate data U - matrix(runif(4000), ncol=4) ## define panel function for colorizing the panels mypanel -

[R] Fwd: How to access the panel rows/columns in pairs()?

2012-01-21 Thread Marius Hofert
okay, I found something. Not very elegant, but it does the job: ## generate data U - matrix(runif(4000), ncol=4) ## define panel function for colorizing the panels cols - c(blue, black, black, blue, black, black, black, black, green, black, black, green) count - 0

Re: [R] How to color a region in a contour plot with the contour being the boundary?

2012-01-03 Thread Marius Hofert
, 0) levelplot(z ~ x * y, dat, at=c(-1, 0.02, 1, 5, 10, 20, 50, 500, 900), labels=TRUE, contour=TRUE, colorkey=FALSE, col.regions=gray(c(0.2, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1))) Jean Marius Hofert wrote on 12/31/2011 05:02:22 AM: Dear expeRts, I

[R] How to color a region in a contour plot with the contour being the boundary?

2011-12-31 Thread Marius Hofert
Dear expeRts, I would like to color a certain region in a levelplot. The region for z = 0.02 should have a dark gray color. Below is a minimal example. It almost does what I want, but The region between z=0.02 and z=1 is also colored in dark gray (instead of just the region for z = 0.02). How

[R] acast: how to obtain names?

2011-11-18 Thread Marius Hofert
Hi, After applying acast() I typically have to adjust the names of the array by hand. Is there any way to tell acast to do this automatically? Cheers, Marius require(reshape2) (df - data.frame(a=c(a1,a2), b=c(b1,b2), c=c(c1,c2))) a.df - acast(df, a~b, value_var=c) names(dimnames(a.df)) # =

[R] rgl: axis/viewport/box problems in persp3d()

2011-09-09 Thread Marius Hofert
Dear expeRts, I am a new user of rgl, below is my first trial to plot a simple function in 3d. I managed to put the axes in the right locations, but: (1) The xlab, ylab, and zlab arguments are ignored; how can I put in axes labels? (2) Since I removed the axes in persp3d() the viewport is too

Re: [R] rgl: axis/viewport/box problems in persp3d()

2011-09-09 Thread Marius Hofert
rgl.postscript(myplot.pdf, fmt=pdf) # print to file rgl.viewpoint(zoom=pl$zoom, fov=pl$FOV, userMatrix=pl$userMatrix, interactive=FALSE) # set the viewpoint for the next plot to make sure it looks the same On 2011-09-09, at 12:41 , Duncan Murdoch wrote: On 11-09-09 6:18 AM, Marius Hofert wrote: Dear

Re: [R] rgl: axis/viewport/box problems in persp3d()

2011-09-09 Thread Marius Hofert
Dear Duncan, thanks a lot. Is it possible to rotate the label drawn by mtext3d, say, by 90 degrees? [a rot=90 did not help] Cheers, Marius On 2011-09-09, at 14:32 , Duncan Murdoch wrote: On 09/09/2011 8:02 AM, Marius Hofert wrote: Dear Duncan, thanks for your quick response. Below

Re: [R] Rgl and plotmath symbols (via sprites): a trial

2011-09-09 Thread Marius Hofert
, Marius Hofert wrote: Dear all, Below is some code where I try to get plotmath symbols in an rgl plot. Duncan Murdoch kindly suggested to use a sprite for this. As you can see, on can get it to work, but my knowledge about grid and rgl is too limited to perfectly solve the problem. 1) As you

Re: [R] Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?

2011-08-18 Thread Marius Hofert
Dear all, okay, I found a one liner based on mutate: (df3 - mutate(df1, Value=Value[order(Year,Group)] / df2[with(df2, order(Year,Group)),Value])) Cheers, Marius On 2011-08-18, at 20:41 , Marius Hofert wrote: Dear expeRts, What is the best approach to create a third data frame from two

[R] How to apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Marius Hofert
Dear all, First, let's create some data to play around: set.seed(1) (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10), Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 10)))[sample(1:30,30),]) ## Now we need the empirical distribution function: edf - function(x)

Re: [R] How to apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Marius Hofert
Dear all, thanks a lot for the quick help. Below is what I built with the hint of Nick. Cheers, Marius library(plyr) set.seed(1) (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10), Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 10)))[sample(1:30,30),]) edf -

Re: [R] lattice: How to vertically adjust an axis label?

2011-07-09 Thread Marius Hofert
dirty, but it solves the problem :-) Cheers, Marius On 2011-07-09, at 24:12 , David Winsemius wrote: On Jul 8, 2011, at 6:54 PM, Marius Hofert wrote: Dear expeRts, How can I vertically adjust an axis tick label so that it is nicely aligned with the other labels? library(lattice

[R] lattice: How to vertically adjust an axis label?

2011-07-08 Thread Marius Hofert
Dear expeRts, How can I vertically adjust an axis tick label so that it is nicely aligned with the other labels? library(lattice) xyplot(0~0, xlim=c(0,3), scales=list(x=list(at=c(1,1.1), labels=c(expression(hat(theta)[italic(n)]),expression(theta) ## aim: move the leftmost expression up so

[R] data.frame: How to get the classes of all components and how to remove their factor structure?

2011-06-28 Thread Marius Hofert
Dear expeRts, I have two questions concerning data frames: (1) How can I apply the class function to each component in a data.frame? As you can see below, applying class to each column is not the right approach; applying it to each component seems bulky. (2) After transforming the data frame a

Re: [R] Odp: data.frame: How to get the classes of all components and how to remove their factor structure?

2011-06-28 Thread Marius Hofert
Dear Petr, thanks for your posts, they perfectly answered my questions. Cheers, Marius On 2011-06-28, at 09:49 , Petr PIKAL wrote: Dear expeRts, I have two questions concerning data frames: (1) How can I apply the class function to each component in a data.frame? As you can see

Re: [R] Tricky (?) conversion from data.frame to matrix where not all pairs exist

2011-06-22 Thread Marius Hofert
HTH, Dennis On Tue, Jun 21, 2011 at 3:13 PM, Marius Hofert m_hof...@web.de wrote: 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

Re: [R] Tricky (?) conversion from data.frame to matrix where not all pairs exist

2011-06-22 Thread Marius Hofert
Hi David, thanks for the quick response. That's nice. Is there also a way without loading an additional package? I'd prefer loading less packages if possible. Cheers, Marius On 2011-06-22, at 15:38 , David Winsemius wrote: On Jun 22, 2011, at 9:19 AM, Marius Hofert wrote: Hi

[R] Tricky (?) conversion from data.frame to matrix where not all pairs exist

2011-06-21 Thread Marius Hofert
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

Re: [R] Tricky (?) conversion from data.frame to matrix where not all pairs exist

2011-06-21 Thread Marius Hofert
:13 PM, Marius Hofert m_hof...@web.de wrote: 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

Re: [R] lattice + plotmath: how to get a variable in bold face?

2011-06-03 Thread Marius Hofert
won't work for symbols, as noted above. Dennis On Thu, Jun 2, 2011 at 3:50 PM, Marius Hofert m_hof...@web.de wrote: 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

[R] plot + axis: Individually moving tick labels with hadj?

2011-06-03 Thread Marius Hofert
Dear all, consider the following plot: plot(1:5, 5:1, xaxt=n) axis(1, at=1:5, labels=c(1,2,expression(3==beta[foo]),4,5)) the label at 3 is not nice, so consider this plot(1:5, 5:1, xaxt=n) axis(1, at=1:5, labels=c(1,2,expression(3==beta[foo]),4,5), padj=c(0,0,0.18,0,0)) Now I

Re: [R] plot + axis: Individually moving tick labels with hadj?

2011-06-03 Thread Marius Hofert
, xaxt=n) axis(1, at=1:5, labels=c(1,2,,4,5)) axis(1, at=3.15, tick=FALSE, labels=expression(3==beta[foo])) Sarah On Fri, Jun 3, 2011 at 7:02 AM, Marius Hofert m_hof...@web.de wrote: Dear all, consider the following plot: plot(1:5, 5:1, xaxt=n) axis(1, at=1:5, labels=c(1,2

  1   2   3   >