[Rd] R for Windows FAQ: Minor comment on "32- and 64-bit" installation paths
In 'R for Windows FAQ' for R version 2.11.0 Patched (2010-05-11 r51982) you can read: [2.29] Can both 32- and 64-bit R be installed on the same machine? Obviously, only relevant if the machine is running a 64-bit version of Windows. Yes, with a little care. For R 2.11.x they should be installed into different directories: the installer will suggest that the 64-bit build is installed into, say, R-2.11.0-x64 and Administrator installs will default to different paths (e.g. C:\Program Files (x86)\R for 32-bit, C:\Program Files\R for 64-bit). The Start Menu, desktop and quick launch icons will be named differently, and the versions can be uninstalled independently. Aren't those paths vice versa? 32-bit: C:\Program Files\R 64-bit: C:\Program Files (x86)\R (I've noticed that this paragraph is not in R v2.12.0 dev). /Henrik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Using Sweave in hostile environments
I'm trying to put together a poster using the LaTeX a0poster package and including some things from pstricks to get gradient shading, etc. The problem is that the default environments used by Sweave don't work where I need them. A simple code chunk like <>= x <- 1 @ buried in a minipage within a psshadowbox gives the error Runaway argument? > x <- 1 \end {Sinput} \end {Schunk} and the resulting variable would\ETC. D:/test.tex:302: Paragraph ended before \FV@ BeginScanning was complete Has anyone solved this problem? One way I see that might work is to put the code chunk outside the environment and use SaveVerbatim to save it, then just put \BUseVerbatim or \LUseVerbatim in place where I need it. But because I'm using Sweave, I somehow need to redefine the Sinput, Soutput and maybe the Schunk environments to do that, and I don't see how to do so. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R for Windows FAQ: Minor comment on "32- and 64-bit" installation paths
On 13.05.2010 09:29, Henrik Bengtsson wrote: In 'R for Windows FAQ' for R version 2.11.0 Patched (2010-05-11 r51982) you can read: [2.29] Can both 32- and 64-bit R be installed on the same machine? Obviously, only relevant if the machine is running a 64-bit version of Windows. Yes, with a little care. For R 2.11.x they should be installed into different directories: the installer will suggest that the 64-bit build is installed into, say, R-2.11.0-x64 and Administrator installs will default to different paths (e.g. C:\Program Files (x86)\R for 32-bit, C:\Program Files\R for 64-bit). The Start Menu, desktop and quick launch icons will be named differently, and the versions can be uninstalled independently. Aren't those paths vice versa? 32-bit: C:\Program Files\R 64-bit: C:\Program Files (x86)\R No: This is MS decision and it is consequent: Under 64-bit Windows, the default is to use 64-bit Applications (hence in "Program Files") and 32-bit applications go into "Program Files (x86)". x86 for the old 32-bit x86 architecture. (I've noticed that this paragraph is not in R v2.12.0 dev). Right, since it is planned to release R-2.12.0 as a bi-arch distribution, i.e. just one installer that contains both 32-bit and 64-bit binaries and will (if you select to install both) install the binaries in subdirectories of bin/ lib/ etc. But this is still heavily under development and the CRAN checks are not yet complete. Uwe Ligges /Henrik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] What functions are called internally in R to resolve what variable is referred?
Hello All, If I refer to a variable 'x', 'x' will be searched in the current frame or the parent frame, or the parent of the parent frame, etc., until it is found (or not found at all)? Could you please show me what code in R source that handles this? Is it in the C code or the R code? Thanks, Tom __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] What functions are called internally in R to resolve what variable is referred?
On May 13, 2010, at 1:16 PM, thmsfuller...@gmail.com wrote: > Hello All, > > If I refer to a variable 'x', 'x' will be searched in the current > frame or the parent frame, or the parent of the parent frame, etc., > until it is found (or not found at all)? Could you please show me what > code in R source that handles this? Is it in the C code or the R code? > At R level it is done automatically during evaluation (but you can so something similar using get() function in R). Internally (in C), findVar(symbol, env) in src/main/envir.c does the job by using findVarInFrame3() recursively for parent environments. There is slight exception if you use x() since that does a search with the restriction that x must be a function and thus uses findFun() instead. Cheers, Simon __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] cdplot() with 'POSIXct' x
Hi, Given that cdplot() is used to produce the conditional density of a categorical y along a numerical x, it seems natural that it could be used with a date or time x (such as 'POSIXct'). Is this desirable? If so, I've created a patch that would allow this, by coercing the POSIXct x variable to produce the density, but use the original POSIXct x to draw the x axis. Index: src/library/graphics/R/cdplot.R === --- src/library/graphics/R/cdplot.R (revision 51984) +++ src/library/graphics/R/cdplot.R (working copy) @@ -43,8 +43,8 @@ if(!is.null(ylevels)) y <- factor(y, levels = if(is.numeric(ylevels)) levels(y)[ylevels] else ylevels) x <- mf[,2] -if(!is.numeric(x)) -stop("explanatory variable should be numeric") +if (!(is.numeric(x) || is(x, "POSIXct"))) +stop("explanatory variable should be numeric or POSIXct") ## graphical parameters if(is.null(xlab)) xlab <- names(mf)[2L] @@ -66,7 +66,8 @@ yaxlabels = NULL, xlim = NULL, ylim = c(0, 1), ...) { ## check x and y -if(!is.numeric(x)) stop("explanatory variable should be numeric") +if (!(is.numeric(x) || is(x, "POSIXct"))) +stop("explanatory variable should be numeric or POSIXct") if(!is.factor(y)) stop("dependent variable should be a factor") if(!is.null(ylevels)) y <- factor(y, levels = if(is.numeric(ylevels)) levels(y)[ylevels] else ylevels) @@ -79,10 +80,12 @@ if(is.null(yaxlabels)) yaxlabels <- levels(y) ## unconditional density of x -dx <- if(is.null(from) & is.null(to)) -stats::density(x, bw = bw, n = n, ...) -else -stats::density(x, bw = bw, from = from, to = to, n = n, ...) +xnum <- as.numeric(x) +dx <- if (is.null(from) & is.null(to)) { +stats::density(xnum, bw = bw, n = n, ...) +} else { +stats::density(xnum, bw = bw, from = from, to = to, n = n, ...) +} x1 <- dx$x ## setup conditional values @@ -94,7 +97,7 @@ rval <- list() for(i in seq_len(ny-1L)) { -dxi <- stats::density(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw, n = n, +dxi <- stats::density(xnum[y %in% levels(y)[seq_len(i)]], bw = dx$bw, n = n, from = min(dx$x), to = max(dx$x), ...) y1[i,] <- dxi$y/dx$y * yprop[i] rval[[i]] <- stats::approxfun(x1, y1[i,], rule = 2) @@ -103,8 +106,8 @@ ## use known ranges y1 <- rbind(0, y1, 1) -y1 <- y1[,which(x1 >= min(x) & x1 <= max(x))] -x1 <- x1[x1 >= min(x) & x1 <= max(x)] +y1 <- y1[,which(x1 >= min(xnum) & x1 <= max(xnum))] +x1 <- x1[x1 >= min(xnum) & x1 <= max(xnum)] if(is.null(xlim)) xlim <- range(x1) if(any(ylim < 0) || any(ylim > 1)) { @@ -120,7 +123,9 @@ for(i in seq_len(NROW(y1)-1)) polygon(c(x1, rev(x1)), c(y1[i+1,], rev(y1[i,])), col = col[i], border = border) -axis(1) +if (is(x, "POSIXct")) { +axis.POSIXct(1, x) +} else axis(1) equidist <- any(diff(y1[,1L]) < tol.ylab) if(equidist) -- Seb __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] What functions are called internally in R to resolve whatvariable is referred?
> From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of > thmsfuller...@gmail.com > Sent: Thursday, May 13, 2010 10:16 AM > To: r-devel@r-project.org > Subject: [Rd] What functions are called internally in R to > resolve whatvariable is referred? > > Hello All, > > If I refer to a variable 'x', 'x' will be searched in the current > frame or the parent frame, or the parent of the parent frame, etc., > until it is found (or not found at all)? Be careful with your terms here. While a function is evaluating its 'parent frame' is the environment of the function that called it and its 'parent environment' is the environment in which it was defined. R searches though the chain of parent environments, not parent frames. The following example shows the difference between the parent environment and the parent frame. # setup x <- "Global x" f1 <- function() { c(x=x, xFromParentFrame=get("x", envir=parent.frame()), xFromParentEnv=get("x", envir=parent.env(environment( } f0 <- function(i) { x<-paste("f0's x: i=", i, sep="") # Note how subf0 and f1 have identical definitions: # they only differ in where they were created. subf0 <- function () { c(x = x, xFromParentFrame = get("x", envir = parent.frame()), xFromParentEnv = get("x", envir = parent.env(environment( } list(subf0=subf0(), f1=f1(), FUN=subf0) } > # run the functions > z <- f0(17) > z $subf0 x xFromParentFrame xFromParentEnv "f0's x: i=17" "f0's x: i=17" "f0's x: i=17" $f1 x xFromParentFrame xFromParentEnv "Global x" "f0's x: i=17" "Global x" $FUN function () { c(x = x, xFromParentFrame = get("x", envir = parent.frame()), xFromParentEnv = get("x", envir = parent.env(environment( } > z$FUN() x xFromParentFrame xFromParentEnv "f0's x: i=17" "Global x" "f0's x: i=17" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > Could you please show me what > code in R source that handles this? Is it in the C code or the R code? > > Thanks, > Tom __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cdplot() with 'POSIXct' x
On Thu, 13 May 2010, Sebastian P. Luque wrote: Hi, Given that cdplot() is used to produce the conditional density of a categorical y along a numerical x, it seems natural that it could be used with a date or time x (such as 'POSIXct'). Is this desirable? If so, I've created a patch that would allow this, by coercing the POSIXct x variable to produce the density, but use the original POSIXct x to draw the x axis. I don't think we should special case "POSIXct". The general question would be whether we allow "x" variables that can be coerced to numeric. The approach would be: - Omit all checking of the original "x". - Compute xorig <- x x <- as.numeric(xorig) and then proceed as before except for one change. - For drawing the axis use Axis(xorig, side = 1) rather than axis(1). This would work for POSIXct, Date, and other classes of the same type, e.g., yearmon in package "zoo". Also, we could easily write time series methods for cdplot() and spineplot() in package "zoo". The downside is that there is no more checking of the "x" argument and weird things could happen without a useful error message when users specify awkward x arguments. I played around with modified versions of cdplot() and also spineplot() (where the new labeling is a bit more involved but based on the same principles) and could supply code/docs for both. So the question is whether the more flexible code with reduced checking is suitable/acceptable for base R or not. Best, Z Index: src/library/graphics/R/cdplot.R === --- src/library/graphics/R/cdplot.R (revision 51984) +++ src/library/graphics/R/cdplot.R (working copy) @@ -43,8 +43,8 @@ if(!is.null(ylevels)) y <- factor(y, levels = if(is.numeric(ylevels)) levels(y)[ylevels] else ylevels) x <- mf[,2] -if(!is.numeric(x)) -stop("explanatory variable should be numeric") +if (!(is.numeric(x) || is(x, "POSIXct"))) +stop("explanatory variable should be numeric or POSIXct") ## graphical parameters if(is.null(xlab)) xlab <- names(mf)[2L] @@ -66,7 +66,8 @@ yaxlabels = NULL, xlim = NULL, ylim = c(0, 1), ...) { ## check x and y -if(!is.numeric(x)) stop("explanatory variable should be numeric") +if (!(is.numeric(x) || is(x, "POSIXct"))) +stop("explanatory variable should be numeric or POSIXct") if(!is.factor(y)) stop("dependent variable should be a factor") if(!is.null(ylevels)) y <- factor(y, levels = if(is.numeric(ylevels)) levels(y)[ylevels] else ylevels) @@ -79,10 +80,12 @@ if(is.null(yaxlabels)) yaxlabels <- levels(y) ## unconditional density of x -dx <- if(is.null(from) & is.null(to)) -stats::density(x, bw = bw, n = n, ...) -else -stats::density(x, bw = bw, from = from, to = to, n = n, ...) +xnum <- as.numeric(x) +dx <- if (is.null(from) & is.null(to)) { +stats::density(xnum, bw = bw, n = n, ...) +} else { +stats::density(xnum, bw = bw, from = from, to = to, n = n, ...) +} x1 <- dx$x ## setup conditional values @@ -94,7 +97,7 @@ rval <- list() for(i in seq_len(ny-1L)) { -dxi <- stats::density(x[y %in% levels(y)[seq_len(i)]], bw = dx$bw, n = n, +dxi <- stats::density(xnum[y %in% levels(y)[seq_len(i)]], bw = dx$bw, n = n, from = min(dx$x), to = max(dx$x), ...) y1[i,] <- dxi$y/dx$y * yprop[i] rval[[i]] <- stats::approxfun(x1, y1[i,], rule = 2) @@ -103,8 +106,8 @@ ## use known ranges y1 <- rbind(0, y1, 1) -y1 <- y1[,which(x1 >= min(x) & x1 <= max(x))] -x1 <- x1[x1 >= min(x) & x1 <= max(x)] +y1 <- y1[,which(x1 >= min(xnum) & x1 <= max(xnum))] +x1 <- x1[x1 >= min(xnum) & x1 <= max(xnum)] if(is.null(xlim)) xlim <- range(x1) if(any(ylim < 0) || any(ylim > 1)) { @@ -120,7 +123,9 @@ for(i in seq_len(NROW(y1)-1)) polygon(c(x1, rev(x1)), c(y1[i+1,], rev(y1[i,])), col = col[i], border = border) -axis(1) +if (is(x, "POSIXct")) { +axis.POSIXct(1, x) +} else axis(1) equidist <- any(diff(y1[,1L]) < tol.ylab) if(equidist) -- Seb __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] results of pnorm as either NaN or Inf
I stumbled across this and I am wondering if this is unexpected behavior or if I am missing something. > pnorm(-1.0e+307, log.p=TRUE) [1] -Inf > pnorm(-1.0e+308, log.p=TRUE) [1] NaN Warning message: In pnorm(q, mean, sd, lower.tail, log.p) : NaNs produced > pnorm(-1.0e+309, log.p=TRUE) [1] -Inf I don't know C and am not that skilled with R, so it would be hard for me to look into the code for pnorm. If I'm not just missing something, I thought it may be of interest. Details: I am using Mac OS X 10.5.8. I installed a precompiled binary version. Here is the output from sessionInfo(), requested in the posting guide: R version 2.11.0 (2010-04-22) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.11.0 Thank you very much, Eric Freeman UC Berkeley __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] results of pnorm as either NaN or Inf
On 13-May-10 20:04:50, efree...@berkeley.edu wrote: > I stumbled across this and I am wondering if this is unexpected > behavior or if I am missing something. > >> pnorm(-1.0e+307, log.p=TRUE) > [1] -Inf >> pnorm(-1.0e+308, log.p=TRUE) > [1] NaN > Warning message: > In pnorm(q, mean, sd, lower.tail, log.p) : NaNs produced >> pnorm(-1.0e+309, log.p=TRUE) > [1] -Inf > > I don't know C and am not that skilled with R, so it would be hard > for me to look into the code for pnorm. If I'm not just missing > something, I thought it may be of interest. > > Details: > I am using Mac OS X 10.5.8. I installed a precompiled binary version. > Here is the output from sessionInfo(), requested in the posting guide: > R version 2.11.0 (2010-04-22) > i386-apple-darwin9.8.0 > > locale: > [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] tools_2.11.0 > > Thank you very much, > > Eric Freeman > UC Berkeley This is probably platform-independent. I get the same results with R on Linux. More to the point: You are clearly "pushing the envelope" here. First, have a look at what R makes of your inputs to pnorm(): -1.0e+307 # [1] -1e+307 -1.0e+308 # [1] -1e+308 -1.0e+309 # [1] -Inf So, somewhere beteen -1e+308 and -1.0e+309. the envelope burst! Given -1.0e+309, R returns -Inf (i.e. R can no longer represent this internally as a finite number). Now look at pnorm(-Inf,log.p=TRUE) # [1] -Inf So, R knows how to give the correct answer (an exact 0, or -Inf on the log scale) if you feed pnorm() with -Inf. So you're OK with -1e+N where N >= 309. For smaller powers, e.g. -1e+(200:306), these give pnorm() much less than -1.0e+309, and presumably R's algorithm (which I haven't studied either ... ) returns 0 for pnorm(), as it should to the available internal accuracy. So, up to pnorm(-1.0e+307, log.p=TRUE) = -Inf. All is as it should be. However, at -1e+308, "the envelope is about to burst", and something may occur within the algorithm which results in a NaN. So there is nothing anomalous about your results except at -1e+308, which is where R is at a critical point. That's how I see it, anway! Ted. E-Mail: (Ted Harding) Fax-to-email: +44 (0)870 094 0861 Date: 14-May-10 Time: 00:01:27 -- XFMail -- __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] where is libRmath.a & libRmath.so
I see Rmath.h in include. Why can't I find libRmath.a and/or libRmath.so? -- View this message in context: http://r.789695.n4.nabble.com/where-is-libRmath-a-libRmath-so-tp2216048p2216048.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] discrete-time survival model
Dear List, Last week, I asked on R-help if there was a package implementing the dynamic discrete time model of Fahrmeir (1994) - http://www.jstor.org/pss/2336962. Unfortunately, nobody answered. So I start to implement it. Does anyone interested in such development? Or is it useless because someone has already implemented this model? In the coming days, I plan to move my code on R-forge, so people can easily contribute. If you are interested please let me know. Thanks in advance Christophe -- Christophe Dutang Ph.D. student at ISFA, Lyon, France website: http://dutangc.free.fr [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel