[Rd] Example of environment

2006-04-04 Thread Henrik Bengtsson
A minor comment: in help(environment) the example starts with: ##-- all three give the same: environment() environment(environment) .GlobalEnv but the comment is not true. The second returns the "". "R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.0 alph

Re: [Rd] Integration of C and Fortran

2006-04-04 Thread Prof Brian Ripley
Is the enter point Fortran "orderdata_" absent of the loading table. a manual translation, and was the underscore there in the original (I think it should be, but am just checking). What do nm -g mpackage.so tell you is actually exported from the shared object (here called 'mypackag

Re: [Rd] Example of environment

2006-04-04 Thread Duncan Murdoch
On 4/4/2006 4:33 AM, Henrik Bengtsson wrote: > A minor comment: in help(environment) the example starts with: > > ##-- all three give the same: > environment() > environment(environment) > .GlobalEnv > > but the comment is not true. The second returns the " namespace:base>". > > "

Re: [Rd] Build failure with this morning's R-alpha

2006-04-04 Thread Dirk Eddelbuettel
On 4 April 2006 at 07:12, Prof Brian Ripley wrote: | Note that libR.so was itself linked against -lm, so should resolve its | dependencies there. The front end has never been linked against -lm, nor | do I see that anything should have changed for a long time in the | front-end. Thanks for con

Re: [Rd] Extending www.r-project.org features with a Wiki (PR#8744)

2006-04-04 Thread Philippe Grosjean
http://wiki.r-project.org is quite recent and not widely advertised yet because I want to finialize features and beta test them with a limited number of enthousiast people *before* making more publicity about it. It is dedicated to the kind of collaborative documentation that Victor Anyakin is

[Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
Hi, this relates to the question "How to set a former environment?" asked yesterday. What is the best way to to return a function with a minimal environment from a function? Here is a dummy example: foo <- function(huge) { scale <- mean(huge) function(x) { scale * x } } fcn <- foo(1:10e5)

Re: [Rd] change function's formals default values

2006-04-04 Thread Thomas Lumley
On Mon, 3 Apr 2006, Andrew Finley wrote: > Hello, > > I'm passing a user defined function into my c code. Once this function > is in my c code, I'd like to iteratively change the values associated > with the parameters defined in the function's formal list then evaluate > the function using these

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Thomas Lumley
On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > Hi, > > this relates to the question "How to set a former environment?" asked > yesterday. What is the best way to to return a function with a > minimal environment from a function? Here is a dummy example: > > foo <- function(huge) { > scale <- mean

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Roger D. Peng
In R 2.3.0-to-be, I think you can do foo <- function(huge) { scale <- mean(huge) g <- function(x) { scale * x } environment(g) <- emptyenv() g } -roger Henrik Bengtsson wrote: > Hi, > > this relates to the question "How to set a former environment?" asked > yeste

Re: [Rd] change function's formals default values

2006-04-04 Thread Andrew Finley
Hi Thomas, Thanks for the note. I'm not sure about a lot of things. Setting the formal defaults then calling the function seem straight forward. I just assumed it would be like setting list values, or the C equivalent of calling formals(fn)<-list(a=1, b=3). Following your suggestion, I can get

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Prof Brian Ripley
On Tue, 4 Apr 2006, Roger D. Peng wrote: > In R 2.3.0-to-be, I think you can do > > foo <- function(huge) { > scale <- mean(huge) > g <- function(x) { scale * x } > environment(g) <- emptyenv() > g > } You can, but you really don't want to and you will get the same error.

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > Hi, > > > > this relates to the question "How to set a former environment?" asked > > yesterday. What is the best way to to return a function with a > > minimal environment from a function? Here

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Gabor Grothendieck
On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > Hi, > > > > > > this relates to the question "How to set a former environment?" asked > > > yesterday. What is the best way to to r

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Martin Maechler
> "Roger" == Roger D Peng <[EMAIL PROTECTED]> > on Tue, 04 Apr 2006 10:38:29 -0400 writes: Roger> In R 2.3.0-to-be, I think you can do Roger> foo <- function(huge) { Roger> scale <- mean(huge) Roger> g <- function(x) { scale * x } Roger> environment(g) <- emptyenv(

[Rd] request to add argv[0]

2006-04-04 Thread ivo welch
Dear R Developers: This has come up repeatedly in the r-help mailing list, most recently in a thread started by myself. The answers have been changing over the years. Would it be possible and easy for R to offer a global read-only option that gives the name of the currently executing R script, i

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Tue, 4 Apr 2006, Roger D. Peng wrote: > > > In R 2.3.0-to-be, I think you can do > > > > foo <- function(huge) { > > scale <- mean(huge) > > g <- function(x) { scale * x } > > environment(g) <- emptyenv() > > g > >

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Henrik Bengtsson
On 4/4/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > > > Hi, > > > > > > > > this relates to the question "How to set a fo

Re: [Rd] request to add argv[0]

2006-04-04 Thread Roger D. Peng
ivo welch wrote: > Dear R Developers: This has come up repeatedly in the r-help mailing > list, most recently in a thread started by myself. The answers have > been changing over the years. Would it be possible and easy for R to > offer a global read-only option that gives the name of the curr

[Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Bill Dunlap
strsplit() is a convenient way to get a list of items from a string when you have a regular expression for what is not an item. E.g., > strsplit("1.2, 34, 1.7e-2", split="[ ,] *") [[1]]: [1] "1.2""34" "1.7e-2" However, sometimes is it more convenient to give a pattern for the it

Re: [Rd] Return function from function with minimal environment

2006-04-04 Thread Gabor Grothendieck
On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On 4/4/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > On 4/4/06, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > > > On 4/4/06, Thomas Lumley <[EMAIL PROTECTED]> wrote: > > > > On Tue, 4 Apr 2006, Henrik Bengtsson wrote: > > > > > > > >

Re: [Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Gabor Grothendieck
gsubfn in package gsubfn can do this. See the examples in ?gsubfn On 4/4/06, Bill Dunlap <[EMAIL PROTECTED]> wrote: > strsplit() is a convenient way to get a > list of items from a string when you > have a regular expression for what is not > an item. E.g., > > > strsplit("1.2, 34, 1.7e-2", s

Re: [Rd] change function's formals default values

2006-04-04 Thread Thomas Lumley
On Tue, 4 Apr 2006, Andrew Finley wrote: > Hi Thomas, > > Thanks for the note. I'm not sure about a lot of things. Setting the > formal defaults then calling the function seem straight forward. I just > assumed it would be like setting list values, or the C equivalent of > calling formals(fn)<-li

Re: [Rd] change function's formals default values

2006-04-04 Thread Andrew Finley
Your example is perfectly clear. I'll take your suggestion. Thanks a lot for your time- Andrew On Tue, 2006-04-04 at 10:00 -0700, Thomas Lumley wrote: > On Tue, 4 Apr 2006, Andrew Finley wrote: > > > Hi Thomas, > > > > Thanks for the note. I'm not sure about a lot of things. Setting the > > forma

Re: [Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Bill Dunlap
On Tue, 4 Apr 2006, Gabor Grothendieck wrote: > gsubfn in package gsubfn can do this. See the examples > in ?gsubfn Thanks. gsubfn looks useful, but may be overkill for this, and it isn't vectorized. To do what strsplit(keep=T) would do I think you need to do something like: > findMatches<

Re: [Rd] extending strsplit(): supply pattern to keep, not to split by

2006-04-04 Thread Gabor Grothendieck
On 4/4/06, Bill Dunlap <[EMAIL PROTECTED]> wrote: > On Tue, 4 Apr 2006, Gabor Grothendieck wrote: > > > gsubfn in package gsubfn can do this. See the examples > > in ?gsubfn > > Thanks. gsubfn looks useful, but may be overkill > for this, and it isn't vectorized. To do what gsubfn is vectorized

Re: [Rd] Build failure with this morning's R-alpha

2006-04-04 Thread Dirk Eddelbuettel
On 3 April 2006 at 16:11, Dirk Eddelbuettel wrote: | Trying to build a Debian snapshot of R-alpha based on last night's tarball, | it fails with what looks like a missing -lm linking directive: | | [...] | gcc -I. -I../../src/include -I../../src/include -DHAVE_CONFIG_H -fpic -O2 -c Rmain

[Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread cfillekes
Full_Name: c fillekes Version: Version 2.2.1 (2005-12-20 r36812) OS: Gentoo Linux kernel 2.6.12 Submission from: (NULL) (129.116.71.233) "Not Available" is of course not a numeric: R > is.numeric (NA) [1] FALSE But for some reason, all arithmetic operations on NA's are in fact numeric, even

Re: [Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread Antonio, Fabio Di Narzo
2006/4/4, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > Full_Name: c fillekes > Version: Version 2.2.1 (2005-12-20 r36812) > OS: Gentoo Linux kernel 2.6.12 > Submission from: (NULL) (129.116.71.233) > > > > > "Not Available" is of course not a numeric: > R > > > is.numeric (NA) > [1] FALSE In the h

Re: [Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread Duncan Murdoch
On 4/4/2006 3:38 PM, [EMAIL PROTECTED] wrote: > Full_Name: c fillekes > Version: Version 2.2.1 (2005-12-20 r36812) > OS: Gentoo Linux kernel 2.6.12 > Submission from: (NULL) (129.116.71.233) > > > > > "Not Available" is of course not a numeric: > R > >> is.numeric (NA) > [1] FALSE > > But f

Re: [Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread Thomas Lumley
On Tue, 4 Apr 2006, Antonio, Fabio Di Narzo wrote: > So in > NA+NA > the logical is automatically coerced to a numerical value, and > is.numericreturns TRUE, as expected. > > But for some reason, all arithmetic operations on NA's are >> in fact numeric, even if it's with other NA's. >> All arithm

Re: [Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread cheryl fillekes
So this is perfectly consistent then: > A <- NA > B <- NA+NA > B [1] NA > A [1] NA > is.numeric (A) [1] FALSE > is.numeric (B) [1] TRUE > And the test based on value rather than type would be: > !is.na(A) [1] FALSE > !is.na(B) [1] FALSE On 4/4/06, Antonio, Fabio Di Narzo <[EMAIL PROTECTED]>

Re: [Rd] is.numeric (NA + NA) is TRUE, should be FALSE (PR#8745)

2006-04-04 Thread Duncan Murdoch
On 4/4/2006 6:38 PM, cheryl fillekes wrote: > So this is perfectly consistent then: > >> A <- NA >> B <- NA+NA >> B > [1] NA >> A > [1] NA A and B both print as NA, but they are stored differently. A is logical, B is numeric. You'll also see this in the following tests: > identical(A, A) [1