Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
On 02/26/2013 05:28 PM, Simon Urbanek wrote: On Feb 26, 2013, at 6:48 PM, Hervé Pagès wrote: On 02/26/2013 03:12 PM, Simon Urbanek wrote: On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) d

Re: [Rd] double bracket stripping names

2013-02-26 Thread Winston Chang
This discussion reminds me of another disanalogy in vector/list double/single-bracket numeric/named indexing. First, here's what happens when the item is present. The behavior is consistent (or at least makes sense) across the different ways of getting the value from vectors and lists: # Named in

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Simon Urbanek
On Feb 26, 2013, at 6:48 PM, Hervé Pagès wrote: > On 02/26/2013 03:12 PM, Simon Urbanek wrote: >> >> On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: >> >>> Hi, >>> >>> So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS >>> package (if it's installed), (2) does not pollute the sea

Re: [Rd] double bracket stripping names

2013-02-26 Thread Hervé Pagès
Hi Patrick, On 02/26/2013 02:30 AM, Patrick Burns wrote: Is it on purpose that `[[` strips the names when used on an atomic vector? > c(a=1, b=2)[1] a 1 > c(a=1, b=2)[[1]] [1] 1 FWIW, here are a couple of other interesting facts about this: (a) [[ is about twice faster than [ for me (64-b

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
On 02/26/2013 03:12 PM, Simon Urbanek wrote: On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) does not pollute the search path, (3) no 'R CMD check' warning if MASS is listed in Suggests, and

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Simon Urbanek
On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: > Hi, > > So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS > package (if it's installed), (2) does not pollute the search path, > (3) no 'R CMD check' warning if MASS is listed in Suggests, > and (4) descent error message if MASS is

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) does not pollute the search path, (3) no 'R CMD check' warning if MASS is listed in Suggests, and (4) descent error message if MASS is not installed: > MASS::huber(1:10) Error in loadNamespa

Re: [Rd] Running R scripts with interactive-style evaluation

2013-02-26 Thread Jon Clayden
If you're intending to run some code that may require user input, then I share your need. I started two threads on this some time ago [1,2], but as far as I know it still isn't possible. My workaround is to use "expect", or to create a temporary .Rprofile if that is not available, from within a she

Re: [Rd] double bracket stripping names

2013-02-26 Thread Hadley Wickham
> Yes, as Brian said. And this makes sense: the names are a property of the > container, not a property of the contents. Using single brackets creates a > new container with a subset of the elements. Using double brackets extracts > an element. > > The fact that there's no way to hold a number

Re: [Rd] Running R scripts with interactive-style evaluation

2013-02-26 Thread William Dunlap
Which part of the read-eval-print loop loop ("REPL loop") do you need? source(file, print=TRUE) gives you the printing part, which is what I usually want. Opening a file connection and repeatedly calling parse(n=1) gives you the read part, > tf <- tempfile() > cat(file=tf, sep="\n", "x <- 1

Re: [Rd] double bracket stripping names

2013-02-26 Thread Duncan Murdoch
On 13-02-26 5:30 AM, Patrick Burns wrote: Is it on purpose that `[[` strips the names when used on an atomic vector? > c(a=1, b=2)[1] a 1 > c(a=1, b=2)[[1]] [1] 1 Yes, as Brian said. And this makes sense: the names are a property of the container, not a property of the contents. Using

Re: [Rd] Running R scripts with interactive-style evaluation

2013-02-26 Thread Duncan Murdoch
On 13-02-26 5:07 AM, Marc Aurel Kiefer wrote: Hi, when running a R-script like this: enable_magic() compute_stuff() disable_magic() the whole script is parsed into a single expression and then evaluated, whereas when using the interactive shell after each line entered, a REPL loop happens.

[Rd] Running R scripts with interactive-style evaluation

2013-02-26 Thread Marc Aurel Kiefer
Hi, when running a R-script like this: enable_magic() compute_stuff() disable_magic() the whole script is parsed into a single expression and then evaluated, whereas when using the interactive shell after each line entered, a REPL loop happens. Is there a way to make a script evaluation behave

Re: [Rd] double bracket stripping names

2013-02-26 Thread Prof Brian Ripley
On 26/02/2013 10:30, Patrick Burns wrote: Is it on purpose that `[[` strips the names when used on an atomic vector? Yes, and documented! It does when used on a list, so is consistent. ‘"[["’ can be used to select a single element _dropping_ ‘names’, whereas ‘"["’ keeps them,

[Rd] double bracket stripping names

2013-02-26 Thread Patrick Burns
Is it on purpose that `[[` strips the names when used on an atomic vector? > c(a=1, b=2)[1] a 1 > c(a=1, b=2)[[1]] [1] 1 > sessionInfo() R Under development (unstable) (2013-02-11 r61902) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Milan Bouchet-Valat
Le lundi 25 février 2013 à 12:59 -0800, Davor Cubranic a écrit : > I haven't gotten any complaints from "R CMD check" when I used Simon's > suggestion, even with "--as-cran" flag. Hadley's suggestion to use > 'require' also works, and its side-effect of attaching the other > package can in some app