[R] reticulate via callr

2025-04-09 Thread Benjamin Tyner
Greetings, I would like to programmatically interact with multiple versions of a given Python module via the reticulate package, without having to restart the R process over and over. (My understanding is reticulate does not provide such a capability by itself, as once reticulate binds to a P

Re: [R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-02 Thread Benjamin Tyner
r to that date. On 3/2/24 02:42, Ivan Krylov wrote: В Fri, 1 Mar 2024 10:46:53 -0500 Benjamin Tyner пишет: my platform info: Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.4 LTS Quick things first: have you installed all the build-dependencies? apt build-d

[R] dput(..., file = stderr())

2024-03-01 Thread Benjamin Tyner
Curious to know if this warning is expected behavior, and if so, what is the recommended way instead: > dput(letters, file = stderr()) c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z") Warning messa

[R] installation: while running make, unable to run pdflatex on 'NEWS.tex'

2024-03-01 Thread Benjamin Tyner
A kind member of R-core suggested this is due to a misconfiguration on my system, and to post it to the mailing list for troubleshooting. When trying to build R version 4.3.3, in at least two places during the process it gives LaTeX errors of the form: (example 1) you should 'make docs

[R] .BaseNamespaceEnv locking in non-interactive mode

2022-11-23 Thread Benjamin Tyner
Greetings, Noticed that starting with R version 4.1.0, the base environment is locked by default. So for example in interactive mode, we have > .BaseNamespaceEnv$foo <- "bar" Error in .BaseNamespaceEnv$foo <- "bar" :   cannot add binding of 'foo' to the base environment However it appears tha

Re: [R] chaining closure arguments on-the-fly

2020-06-21 Thread Benjamin Tyner
On 6/20/20 5:04 PM, Duncan Murdoch wrote: I think you effectively did that in your original post (all but encapsulating the expression in a function), so yes, it's possible. However, it's a really bad idea.  Why use non-standard evaluation when standard evaluation is fine?  Standard evaluation

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
On 6/20/20 5:49 PM, Bert Gunter wrote: Gents: (with trepidation) f(x = 3, y = g(expr)) **already** evaluates g in the environment of f, **not** in the environment of the caller. (This does not contradict Duncan's example -- 3 is a constant, not a variable). e.g. > f <- function(x = 3, y =

Re: [R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
On 6/20/20 9:00 AM, Duncan Murdoch wrote: How about g <- function(x, y = x) {   f(x, y) } g(x = 3) or even yEqualsX <- function(f) function(x, y = x) f(x, y) yEqualsX(f)(x = 3) These are a lot like currying, but aren't currying, so they may be acceptable to you.  Personally I'd choose the f

[R] chaining closure arguments on-the-fly

2020-06-20 Thread Benjamin Tyner
Greetings, Occasionally, I desire to call a function with one argument set to equal to another. Here is a toy example:    f <- function(x, y) {        x + y    }    f(x = 3, y = x) # Error in f(x = 3, y = x) : object 'x' not found So far, the most concise way I found to accomplish this is:

[R] safest way to subset (and replace) a data.table

2019-12-07 Thread Benjamin Tyner
Hi I would like to replace a data.table 'DT' with a subset of itself, where the subset is determined by an expression 'expr' which evaluates to logical. Thus far I've been using:    DT <- DT[expr, ] however this frequently results in a SIGABRT from glibc of the form:    "double free or corr

[R] Matrix::bdiag doesn't like being given a single named argument

2019-05-31 Thread Benjamin Tyner
Hello, Perhaps not a bug, but interesting because the error only happens when there is a single named argument.    > m <- matrix(1, 1, 1)    > library(Matrix)    > bdiag(m)    1 x 1 sparse Matrix of class "dgCMatrix"    [1,] 1    > bdiag(a = m)    Error in is.list(...) : supplied argument nam

Re: [R] undo compile? (or: remove bytecode from closure)

2018-07-16 Thread Benjamin Tyner
pe this helps, Rui Barradas Às 03:25 de 16-07-2018, Benjamin Tyner escreveu: Hi Given a closure which has been compiled, what's the recommended way to recover the original? For example,       > f <- function(x) x+1       > fc <- cmpfun(f)       > rm(f)       > fc       funct

[R] undo compile? (or: remove bytecode from closure)

2018-07-15 Thread Benjamin Tyner
Hi Given a closure which has been compiled, what's the recommended way to recover the original? For example,     > f <- function(x) x+1     > fc <- cmpfun(f)     > rm(f)     > fc     function(x) x+1     what's the best way to recover f from fc ? Regards Ben ___

[R] system() or pipe(..., open = "r") without child process?

2018-05-22 Thread Benjamin Tyner
Greetings On linux, is it possible to invoke an OS command from within R without spawning a child process? If not, is it possible to avoid copying the "parts of the caller's context" that are mentioned on the clone manpage?  ENOMEM Cannot  allocate  sufficient memory to allocate a task struct

Re: [R] rJava garbage collect

2018-02-06 Thread Benjamin Tyner
esolve the issue. Regards Ben On 6 February 2018 at 04:34, Benjamin Tyner https://stat.ethz.ch/mailman/listinfo/r-help>> wrote: >/Hi />//>/Does rJava offer a way to instruct the JVM to perform a garbage col

Re: [R] rJava garbage collect

2018-02-06 Thread Benjamin Tyner
Thanks Jeff; indeed it works:    .jcall("java/lang/System", method = "gc") On 02/05/2018 11:53 PM, Jeff Newmiller wrote: rJava offers a mechanism to call arbitrary methods in Java. Wouldn't you use that mechanism to call whatever you would call if you were programming in Java (e.g. System.gc

[R] rJava garbage collect

2018-02-05 Thread Benjamin Tyner
Hi Does rJava offer a way to instruct the JVM to perform a garbage collection? Regards Ben __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

[R] setSessionLimit

2018-01-19 Thread Benjamin Tyner
Hello The doc/NEWS.2 file mentions a setSessionLimit function, added with version 2.8.0     o   setTimeLimit() function to set limits on the CPU     and/or elapsed time for each top-level computation, and     setSessionLimit() to set limits for the rest of the session. However, I no l

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-24 Thread Benjamin Tyner
, colClasses = c(y = "character", x = "numeric"), col.names = c("foo", "bar"))      foo  bar    1   a 3.14 so I agree it is good that we are checking for that now. Regards Ben On 10/24/2017 08:55 AM, Martin Maechler wrote: Benjamin Tyner

Re: [R] read.table(..., header == FALSE, colClasses = )

2017-10-24 Thread Benjamin Tyner
Jeff, Thank you for your reply. The intent was to construct a minimum reproducible example. The same warning occurs when the 'file' argument points to a file on disk with a million lines. But you are correct, my example was slightly malformed and in fact gives an error under R version 3.2.2.

[R] read.table(..., header == FALSE, colClasses = )

2017-10-23 Thread Benjamin Tyner
Hello I noticed that starting with R version 3.3.0 onward, this generates a warning:    > txt <- c("a", "3.14")    > read.table(file = textConnection(txt), header = FALSE, colClasses = c(x = "character", y = "numeric")) the warning is "not all columns named in 'colClasses' exist" and I gues

[R] flushing on.exit prior to q()

2017-02-21 Thread Benjamin Tyner
Hi, When using a custom error function that calls q(), what is the recommended way to "flush" the calling function's on.exit ? For example, say I have a script: #!/usr/bin/Rscript --no-init-file options(error = function() { cat("on error message\n", file = stderr()) q(sav

Re: [R] [FORGED] file.exists() on device files

2017-01-13 Thread Benjamin Tyner
Thank you for the insights, Rolf and Henrik. To give another example, this time in non-interactive mode, Rscript -e "file.exists(commandArgs(TRUE))" <(echo "Hi") [1] TRUE versus Rscript -e "normalizePath(commandArgs(TRUE))" <(echo "Hi") [1] "/dev/fd/63" Warning message: In n

[R] file.exists() on device files

2017-01-11 Thread Benjamin Tyner
Hi, On my linux machine (Ubuntu, and also tested on RHEL), I am curious to know what might be causing file.exists (and also normalizePath) to not see the final device file here: > list.files("/dev/fd", full.names = TRUE) [1] "/dev/fd/0" "/dev/fd/1" "/dev/fd/2" "/dev/fd/3" > file.exis

Re: [R] modify the imported version of a function

2016-12-19 Thread Benjamin Tyner
= FALSE, dotall = FALSE, ...) { options <- stri_opts_regex(case_insensitive = ignore_case, multiline = multiline, comments = comments, dotall = dotall, ...) structure(pattern, options = options, class = c("regex", "patt

[R] modify the imported version of a function

2016-12-16 Thread Benjamin Tyner
Hi I saw on the assignInNamespace help page, that it changes "the copy in the namespace, but not any copies already exported from the namespace, in particular an object of that name in the package (if already attached) and any copies already imported into other namespaces." So now I'm wonder

[R] R_DirtyImage and Rprof

2016-05-11 Thread Benjamin Tyner
Hello, I have some code which was running in interactive mode while Rprof(..., line.profiling = TRUE). Near the end of my script, it opens up a pipe(..., open = "w") to a perl script, and at that point the execution gets stuck using 100% cpu. (The perl script itself never showed up in pstree

Re: [R] choropleth packages (US)

2015-12-10 Thread Benjamin Tyner
ec 7, 2015 at 9:34 AM, Erich Neuwirth wrote: ggplot2 also can do this with fortify geom_polygon Von meinem iPad gesendet Am 06.12.2015 um 21:03 schrieb Benjamin Tyner : Hi I wish to draw a basic choropleth (US, by state) and am wondering if anyone has any recommendations? I've t

[R] choropleth packages (US)

2015-12-06 Thread Benjamin Tyner
Hi I wish to draw a basic choropleth (US, by state) and am wondering if anyone has any recommendations? I've tried the following thus far: 1. choroplethr: this works, but required installation of 30+ dependencies. I would prefer something with fewer dependencies. 2. tmap: this also seems prom

[R] efficiently multiply each column of a sparse Matrix by a sparse vector

2015-11-28 Thread Benjamin Tyner
Hi, Say I have a sparse Matrix X, and a sparse vector (stored as a 1-column sparse Matrix A), with X and A having the same number of rows, and I wish to multiply each column of X by A, but would like the operation to take full advantage of the sparseness of both X and A. In other words I want

Re: [R] backsolve, chol, Matrix, and SparseM

2015-09-25 Thread Benjamin Tyner
path in the first place. By the way, is R-forge still the correct place to report bugs in package:Matrix? Regards Ben On 09/25/2015 04:25 AM, Martin Maechler wrote: > Dear Ben, > >>>>>> Benjamin Tyner >>>>>> on Thu, 24 Sep 2015 13:47:58 -0400 writes:

[R] backsolve, chol, Matrix, and SparseM

2015-09-24 Thread Benjamin Tyner
Hi I have some code which does (on a symmetric matrix 'x') backsolve(chol(x), diag(nrow(x))) and I am wondering what is the recommended way to accomplish this when x is also sparse (from package:Matrix). I know that package:Matrix provides a chol method for such matrices, but not a backsolve

[R] Rprof and system

2015-08-11 Thread Benjamin Tyner
Hi I have an R script which invokes WriteXLS() (from the package of the same name) which as you may know, calls perl via system(). I've noticed that when I enable profiling using Rprof(), when the script gets to the part where perl is called, it gets "stuck": it just sits there using 99-100% CPU a

Re: [R] package implementing continuous binomial?

2015-05-07 Thread Benjamin Tyner
Thanks David! I'll take a look at zipfR. Regards Ben On 05/07/2015 03:10 PM, David Winsemius wrote: > On May 6, 2015, at 7:00 PM, Benjamin Tyner wrote: > >> Hi >> >> I'm wondering if anyone is aware of an R package implementing (i.e., >> providing a pdf

[R] package implementing continuous binomial?

2015-05-06 Thread Benjamin Tyner
Hi I'm wondering if anyone is aware of an R package implementing (i.e., providing a pdf, cdf, and/or quantile function) for the continuous binomial distribution? Specifically the one characterized here: http://www2.math.uni-paderborn.de/fileadmin/Mathematik/AG-Indlekofer/Workshop/Satellite_meetin

Re: [R] non-terminal token lacking children from utils::getParseData

2015-05-02 Thread Benjamin Tyner
Thank you Yihui for also reporting the bug here: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16354 and thank you Duncan for finding the issue and fixing it! I definitely like your idea to report a summary message instead of the long text string. Regards Ben > I tried to reduce the offen

Re: [R] non-terminal token lacking children from utils::getParseData

2015-02-19 Thread Benjamin Tyner
I tried to reduce the offending portion as best I could to a more-or-less minimal example (1136 bytes), which can be downloaded via: wget https://www.dropbox.com/s/74rgxr5x2aalr99/badstring.R then once in R, > b <- parse(file = "~/badstring.R", keep.source = TRUE) > d <- getParseData

[R] quadprog::solve.QP sometimes returns NaNs

2014-09-26 Thread Benjamin Tyner
Hello, Here is an example; hopefully it is reproducible on others' platform: library(quadprog) n <- 66L set.seed(6860) X <- matrix(1e-20, n, n) diag(X) <- 1 Dmat <- crossprod(X) y <- seq_len(n) dvec <- crossprod(X, y) Amat <- diag(n) bvec <- y + runif(n)

[R] scaling of Amat still recommended for quadprog::solve.QP ?

2014-09-25 Thread Benjamin Tyner
Greetings, I ran across this recommendation, to keep the norms of the columns of the Amat on similar scales, https://stat.ethz.ch/pipermail/r-help/2007-September/141335.html However, when I looked at the code, I noticed that the norms are already being calculated: c c calculate the

Re: [R] from cut.Date

2014-09-17 Thread Benjamin Tyner
t; args(cut.Date) function (x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE, ...) I suppose the latter does make sense, given that days, months, years etc are right-continuous functions of time. Regards Ben > On 17/09/2014 12:04, Benjamin Tyner wrote: > >/ Hello, > />/

[R] from cut.Date

2014-09-17 Thread Benjamin Tyner
Hello, I'm wondering if this is expected? > cut(structure(1, class="Date"), structure(c(11100,1), class="Date")) [1] Levels: 2000-05-23 The help page says that "for ‘"Date"’ objects, only ‘"day"’, ‘"week"’, ‘"month"’, ‘"quarter"’ and ‘"year"’ are allowed" [for the 'breaks' a

Re: [R] lattice: packet.number() versus panel.number()

2014-08-27 Thread Benjamin Tyner
On 08/27/2014 02:10 AM, David Winsemius wrote: > On Aug 26, 2014, at 3:25 PM, Benjamin Tyner wrote: > >> Hi, >> >> According to >> https://svn.r-project.org/R-packages/trunk/lattice/R/print.trellis.R, >> >>"[panel.number] is usually the same as, bu

[R] lattice: packet.number() versus panel.number()

2014-08-26 Thread Benjamin Tyner
Hi, According to https://svn.r-project.org/R-packages/trunk/lattice/R/print.trellis.R, "[panel.number] is usually the same as, but can be different from packet.number" and I had been under the impression that as long as the user is not using a custom index.cond nor perm.cond, the panel.numbe

Re: [R] non-interactive subset, `$`, and quotes

2014-06-26 Thread Benjamin Tyner
Duncan, How embarrassing! Thanks. -Ben On 06/26/2014 10:25 PM, Duncan Murdoch wrote: > On 27/06/2014, 4:08 AM, Benjamin Tyner wrote: >> Hi >> >> I know that subset() is not intended for use in programming. However I >> am still curious to learn why, in non-inter

[R] non-interactive subset, `$`, and quotes

2014-06-26 Thread Benjamin Tyner
Hi I know that subset() is not intended for use in programming. However I am still curious to learn why, in non-interactive mode, if I take away the quotes around 'bar' Rscript -e "foo <- list(bar = iris); head(subset(foo$'bar', Species=='setosa'))" Sepal.Length Sepal.Width Petal.Length P

Re: [R] detecting the sourcing of site profile on Startup versus post-Startup

2014-04-24 Thread Benjamin Tyner
- > Sent from my phone. Please excuse my brevity. > > On April 23, 2014 6:11:09 PM PDT, Benjamin Tyner wrote: >> Thanks Duncan! Yes, I considered taking advantage of .First, but was >> concerned that the .First defined by the site profile could be masked &

Re: [R] detecting the sourcing of site profile on Startup versus post-Startup

2014-04-23 Thread Benjamin Tyner
gave was a simplifying assumption, sorry about that). On 04/23/2014 06:55 AM, Duncan Murdoch wrote: On 22/04/2014, 8:59 PM, Benjamin Tyner wrote: Greetings, Is there any way to programmatically detect whether a piece of code is being run within the initial (Startup) sourcing o

[R] detecting the sourcing of site profile on Startup versus post-Startup

2014-04-22 Thread Benjamin Tyner
Greetings, Is there any way to programmatically detect whether a piece of code is being run within the initial (Startup) sourcing of the site profile? For example, say I have a site profile, "/path/to/Rprofile.site". Is there any function "my_func" which would return different values for these tw

Re: [R] package environment versus namespace environment

2014-03-09 Thread Benjamin Tyner
earch path, then functions in the base namespace would no longer be able to see objects in utils? (I realize the answer may be vacuous, since library() does not honor pos=1). Regards, Ben On 03/09/2014 09:09 AM, Duncan Murdoch wrote: On 14-03-08 6:42 PM, Benjamin Tyner wr

Re: [R] package environment versus namespace environment

2014-03-08 Thread Benjamin Tyner
es back in alphabetical order.) Regards Ben On 03/07/2014 11:46 AM, Duncan Murdoch wrote: On 07/03/2014 10:16 AM, Benjamin Tyner wrote: Hello, I realize that a function in (for example, function "head1" below) is unable to see (without resorting to "::", anyw

[R] package environment versus namespace environment

2014-03-07 Thread Benjamin Tyner
Hello, I realize that a function in (for example, function "head1" below) is unable to see (without resorting to "::", anyway) objects in utils (for example, "head" below), since package:base is after package:utils on the search path. However, I'm wondering what is the machinery that allows a fu

Re: [R] retaining comments within functions defined in Rprofile.site

2013-05-25 Thread Benjamin Tyner
gt; > > On Fri, May 24, 2013 at 5:46 PM, Benjamin Tyner <mailto:bty...@gmail.com>> wrote: > > Hi, > > I have some functions defined within etc/Rprofile.site which contain > embedded comments, but it seems the comments get stripped out when the > site

[R] retaining comments within functions defined in Rprofile.site

2013-05-24 Thread Benjamin Tyner
Hi, I have some functions defined within etc/Rprofile.site which contain embedded comments, but it seems the comments get stripped out when the site profile is sourced into the base namespace. I'm thinking I need to enable options(keep.source=TRUE) somewhere prior to the actual sourcing of the sit

Re: [R] holding argument(s) fixed within lapply

2013-03-22 Thread Benjamin Tyner
ple: > > ret2 <- lapply(X=mylist2, >FUN=do.call, >what=function(...) f2(y=Y, ...)) > > Best, > Nello > > -Original Message- > Date: Tue, 12 Mar 2013 22:37:52 -0400 > From: Benjamin Tyner > To: r-help@r-project.org > Subject: Re: [R] hold

Re: [R] holding argument(s) fixed within lapply

2013-03-14 Thread Benjamin Tyner
inal Message- > Date: Tue, 12 Mar 2013 22:37:52 -0400 > From: Benjamin Tyner > To: r-help@r-project.org > Subject: Re: [R] holding argument(s) fixed within lapply > Message-ID: <513fe680.2070...@gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > >

Re: [R] holding argument(s) fixed within lapply

2013-03-12 Thread Benjamin Tyner
Apologies; resending in plain text... Given a function with several arguments, I would like to perform an lapply (or equivalent) while holding one or more arguments fixed to some common value, and I would like to do it in as elegant a fashion as possible, without resorting to wrapping a separate w

[R] holding argument(s) fixed within lapply

2013-03-12 Thread Benjamin Tyner
|Hello, Given a function with several arguments, I would like to perform an lapply (or equivalent) while holding one or more arguments fixed to some common value, and I would like to do it in as elegant a fashion as possible, without resorting to wrapping a separate wrapper for the function if pos

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Benjamin Tyner
Thanks Jim -- I had considered this approach; is there any way to "hide" such arguments from users? Jim Lemon wrote: On 02/17/2013 12:55 PM, Benjamin Tyner wrote: Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is

[R] detecting entry into a recursive function

2013-02-16 Thread Benjamin Tyner
Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint <- function(){ par <- sys.call(-1L)[[1]] grandpar <- sys.call(-2L)[[1]] !identical(par, grandpar) } but this won't work for functions that don't directly

Re: [R] draw.key; getting grobWidth to respect fontfamily="mono"

2012-09-12 Thread Benjamin Tyner
Many thanks Paul, that is a nifty way to do it. Regards Ben Paul Murrell wrote: Hi On 07/09/12 09:35, Benjamin Tyner wrote: Update: seems one way to skin this cat is to add gp = gpar(fontfamily="mono") to the viewport() call itself. If anyone has any suggestions for a rob

Re: [R] draw.key; getting grobWidth to respect fontfamily="mono"

2012-09-06 Thread Benjamin Tyner
Update: seems one way to skin this cat is to add gp = gpar(fontfamily="mono") to the viewport() call itself. If anyone has any suggestions for a robust way to extract this piece information from the key grob itself (it's nested several levels deep), I'm all ears. Thanks Ben __

[R] draw.key; getting grobWidth to respect fontfamily="mono"

2012-09-06 Thread Benjamin Tyner
Hello Within my panel function, I am using draw.key to create a custom key for each panel. I'm trying to use grobWidth to calculate the correct width for the viewport, but it appears to be disregarding the fontfamily when computing the width. Attached is an example; any ideas what I'm doing wr

[R] optparse::parse_args, using equals sign or not

2012-02-08 Thread Benjamin Tyner
Hi We've found that when using parse_args(..., positional_arguments=FALSE), it is permissible to invoke our script with either "--myfoo=bar" or "--myfoo bar"; that is, whether or not the equals sign is present makes no difference, and in fact both usage forms are demonstrated in the optparse

[R] try() with silent=TRUE not preventing printing of error message

2012-01-10 Thread Benjamin Tyner
Hello, We're curious to know why, on builds lacking Tcl/Tk, try(library(tcltk),silent=TRUE) still allows the message to be printed: Error in firstlib(which.lib.loc, package) : Tcl/Tk support is not available on this system though it does succeed in trapping the error condition? Th

[R] installing binary packages across windows cluster

2011-12-09 Thread Benjamin Tyner
Hi Given a "cluster" of identical windows machines all running the same version of R, are there any circumstances where using install.packages() to install a package (say, one that doesn't have any dependencies) on just a single machine, then copying the resulting installed package subdirecto

[R] package / function for monitoring processes?

2011-09-20 Thread Benjamin Tyner
Hi I recall running across a function a while back which would return information about running processes (such as their cpu and memory usage), but I cannot seem to locate it. Wondering if someone would be kind enough to refresh my memory. I vaguely recall it was parsing the output of the 'ps

Re: [R] 'Rscript -e' and stdout() puzzle

2011-06-23 Thread Benjamin Tyner
Thanks Bill! Next time, I'll try literacy. William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Benjamin Tyner Sent: Thursday, June 23, 2011 5:31 PM To: r-help@r-project.org Subject: [R] 'Rscript -e&#

[R] 'Rscript -e' and stdout() puzzle

2011-06-23 Thread Benjamin Tyner
Hello, I am curious to know why the output of Rscript -e "cat(R.version.string,stdout())" includes a trailing " 1", whereas Rscript -e "cat(R.version.string)" does not. I have tried various mechanisms to subvert this behavior, such as Rscript -e "invisible(con<-stdout()); cat(R.vers

Re: [R] best practice(s) for retrieving a local variable from a closure

2011-04-09 Thread Benjamin Tyner
Thanks Bill and Gabor! William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Benjamin Tyner Sent: Friday, April 08, 2011 6:48 PM To: r-help@r-project.org Subject: [R] best practice(s) for retrieving a local

[R] best practice(s) for retrieving a local variable from a closure

2011-04-08 Thread Benjamin Tyner
Greetings, Say I have defined mp <- function(a) function(x) x^a f2 <- mp(2) and I would like to retrieve the "a" which is local to f2. Two options come to mind; get("a", envir=environment(f2)) eval(substitute(a), environment(f2)) I'm curious if one of these is preferred over the other

Re: [R] lattice: par.settings: custom axis.line by panel

2011-04-08 Thread Benjamin Tyner
ion(x,y,...){ panel.polygon(x = c(0.4,0.6,0.6,0.4), y = c(-10,-10,10,10), col = "yellow") panel.xyplot(x,y,...) } then the bottom border on panel 1 is obscured...any suggestions? Thanks again, Ben Deepayan Sarkar wrote: On Fri, Apr 8, 2011

[R] lattice: par.settings: custom axis.line by panel

2011-04-07 Thread Benjamin Tyner
Hello, In lattice, is there a way to customize the axis.line by panel? For example, say I have two panels: Data <- data.frame(x=runif(10), y=rnorm(10), f=gl(2,5) ) library(lattice) plot <- xyplot(y ~ x|f, data = Data,

Re: [R] dump() an object of type raw ?

2009-07-21 Thread Benjamin Tyner
Thank you David for taking the time to respond to my question. Perhaps I should clarify: the man page says "a 'dump' file can be 'source'd"; have I taken the documentation too literally in this case? David Winsemius wrote: On Jul 21, 2009, at 7:19 PM, Benjamin

[R] dump() an object of type raw ?

2009-07-21 Thread Benjamin Tyner
Is there a way to do this? I tried x <- writeBin(pi, raw()) dump("x","x.R") source("x.R") but is seems x.R is not source()-able, as it contains an unexpected symbol. Thanks Ben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/l

Re: [R] lattice::xyplot axis padding with fontfamily="mono"

2009-05-28 Thread Benjamin Tyner
Deepayan, Many thanks for the quick response and suggested workaround. Best, Ben Deepayan Sarkar wrote: On Wed, May 27, 2009 at 4:38 PM, Benjamin Tyner wrote: Hello, Say I have a predictor taking a very wide value: Data <- data.frame(pred="a

[R] lattice::xyplot axis padding with fontfamily="mono"

2009-05-27 Thread Benjamin Tyner
Hello, Say I have a predictor taking a very wide value: Data <- data.frame(pred="a",resp=1) print(xyplot(pred~resp, data=Data)) # enough y-axis padding to accommodate the wide label print(xyplot(pred~resp, data=Data,scales=list(fontfamily="mono

Re: [R] get() versus getAnywhere()

2009-04-16 Thread Benjamin Tyner
Many thanks Duncan. Perhaps this merits a more explicit note in the documentation? Duncan Murdoch wrote: On 4/16/2009 9:52 AM, Benjamin Tyner wrote: Hi Using R 2.8.1. I have list object called "AuxData". Inside a browser(), get("AuxData") succeeds, while

[R] get() versus getAnywhere()

2009-04-16 Thread Benjamin Tyner
Hi Using R 2.8.1. I have list object called "AuxData". Inside a browser(), get("AuxData") succeeds, while getAnywhere("AuxData") fails with the error "no object named âAuxDataâ was found". I'm curious to know if this could be a bug. If yes, I'll try to come up with a reproducible examp

Re: [R] monotonic GAM with more than one term

2009-03-03 Thread Benjamin Tyner
Simon, Many thanks, that is a very helpful example. It seems quite general in that it also works under bs="cr" as well as with fx=TRUE. -Ben There's an example at the end of the pcls help file in version 1.5-0 --- just submitted to CRAN. best, Simon __

[R] monotonic GAM with more than one term

2009-02-25 Thread Benjamin Tyner
Hi, Does anyone know how to fit a GAM where one or more smooth terms are constrained to be monotonic, in the presence of "by" variables or other terms? I looked at the example in ?pcls but so far have not been able to adapt it to the case where there is more than one predictor. For example, requi

[R] corMatrix crashes R 2.5.1 (windows XP) with corARMA structure

2007-10-01 Thread Benjamin Tyner
R-helpers, n <- 100 arcoefs <- c(0.8) macoefs <- c(-0.6) p <- length(arcoefs) q <- length(macoefs) require(nlme) tmp <- corARMA(value=c(arcoefs,macoefs), form=~1, p=p, q=q) Sigma <- corMatrix(tmp, covariate = 1:n) # results in segfault Have I used these commands in an improper way? Thanks Ben _