[Rd] install.packages no longer respects quiet = TRUE ?

2015-04-28 Thread Hadley Wickham
> install.packages("plyr", quiet = T)

trying URL 
'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.2/plyr_1.8.2.tgz'
Content type 'application/x-gzip' length 855795 bytes (835 KB)
==
downloaded 835 KB


The downloaded binary packages are in
/tmp/RtmpOcorLA/downloaded_packages


I don't have R 3.1.3 handy, but I'm pretty sure this used to produce no output.

Hadley

-- 
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Inconsistency when naming a vector

2015-04-28 Thread Hadley Wickham
On Mon, Apr 27, 2015 at 8:33 AM, peter dalgaard  wrote:
>
>> On 27 Apr 2015, at 13:48 , Hadley Wickham  wrote:
>>
>> Sometimes the absence of a name is maked by an NA:
>>
>> x <- 1:2
>> names(x)[[1]] <- "a"
>> names(x)
>> # [1] "a" NA
>>
>> Whereas other times its
>>
>> y <- c(a = 1, 2)
>> names(y)
>> # [1] "a" ""
>>
>> Is this deliberate? The help for names() is a bit murky, but an
>> example shows the NA behaviour.
>
> I think it is
>
> (a) impossible to change
> (b) at least somewhat coherent
>
> The situation is partially due to the fact that character-NA is a relative 
> latecomer to the language. In the beginning, there was no real distinction 
> between NA and "NA", causing issues when abbreviating Noradrenaline, North 
> America, Nelson Anderson, etc. At some point, it was decided to fix things 
> up, as far as possible in a backawards compatible way. Some common idioms 
> were retained but others were changed to comply with the rules for other 
> vector types.
>
> We have the empty string convention on (AFAICT) all constructor usages:
>
> c(a=1, 3)
> list(a=1, 3)
> cbind(a=1, 3)
>
> and also in the lists implied by argument matching
>
>> f <- function(...) names(match.call(expand.dots=TRUE))
>> f(a=1,3)
> [1] ""  "a" ""
>
> In contrast, assignment forms have the NA convention. This is consistent with 
> the general rules for complex assignment. E.g. we have
>

Ah, that explanation makes sense. Thanks.

It would be helpful to have a isNamed function that abstracted over
all these differences:

isNamed <- function(x) {
 nms <- names(x)
 if (is.null(nms)) return(rep(FALSE, length(x))

 !is.na(x) && x != ""
}

Hadley


-- 
http://had.co.nz/

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] install.packages no longer respects quiet = TRUE ?

2015-04-28 Thread Dirk Eddelbuettel

On 28 April 2015 at 11:21, Hadley Wickham wrote:
| > install.packages("plyr", quiet = T)
| 
| trying URL 
'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.2/plyr_1.8.2.tgz'
| Content type 'application/x-gzip' length 855795 bytes (835 KB)
| ==
| downloaded 835 KB
| 
| 
| The downloaded binary packages are in
| /tmp/RtmpOcorLA/downloaded_packages
| 
| 
| I don't have R 3.1.3 handy, but I'm pretty sure this used to produce no 
output.

Canot replicate with R 3.2.0 on Ubuntu, and it doesn't matter if I use T or 
TRUE.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] install.packages no longer respects quiet = TRUE ?

2015-04-28 Thread Prof Brian Ripley

On 28 April 2015 at 11:21, Hadley Wickham wrote:
| > install.packages("plyr", quiet = T)
|
| trying URL 
'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.2/plyr_1.8.2.tgz'
| Content type 'application/x-gzip' length 855795 bytes (835 KB)
| ==
| downloaded 835 KB
|
|
| The downloaded binary packages are in
| /tmp/RtmpOcorLA/downloaded_packages
|
|
| I don't have R 3.1.3 handy, but I'm pretty sure this used to produce no 
output.


First, the description is

   quiet: logical: if true, reduce the amount of output.

not 'no output'.

This 'change' is seen only for installs of binary packages.  The 
difference is that the default is now type = "both", and 3.1.3 used type 
= 'binary': adding type = "binary" produces what you expected in 3.2.0, 
and type = "both" is already quieter in R-patched.


(Note that it is rather difficult to test install.packages for Mac 
binaries prior to release as that relies on a 'CRAN distribution' which 
pretty much has to be the default version on the machine.)


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Add first() and last() to utils?

2015-04-28 Thread Gregory Warnes
Hi all,

I've been using first() and last() for some time instead of x[1] and
x[length(x)] for vectors, and I gradually added methods for lists,
matrices, and data.frames.

In preparing the next release of the 'gdata' package (2.16.1) I settled on
these definitions, which harness the existing methods for head() and tail():

# Simply call 'first' or 'last' with a different default value for 'n'.
first <- function(x, n=1, ...) head(x, n=n, ...)
last  <- function(x, n=1, ...) tail(x, n=n, ...)


This works nicely, but Brian noted that packages 'data.table' and 'xts'
also provide functions/S3 methods for head() and/or tail().

Would it make sense to add these definitions to package 'utils' to make
them generally available?

-Greg

-- 
"Whereas true religion and good morals are the only solid foundations of
public liberty and happiness . . . it is hereby earnestly recommended to
the several States to take the most effectual measures for the
encouragement thereof." Continental Congress, 1778

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] R CMD check and missing imports from base packages

2015-04-28 Thread Gábor Csárdi
When a symbol in a package is resolved, R looks into the package's
environment, and then into the package's imports environment. Then, if the
symbol is still not resolved, it looks into the base package. So far so
good.

If still not found, it follows the 'search()' path, starting with the
global environment and then all attached packages, finishing with base and
recommended packages.

This can be a problem if a package uses a function from a base package, but
it does not formally import it via the NAMESPACE file. If another package
on the search path also defines a function with the same name, then this
second function will be called.

E.g. if package 'ggplot2' uses 'stats::density()', and package 'igraph'
also defines 'density()', and 'igraph' is on the search path, then
'ggplot2' will call 'igraph::density()' instead of 'stats::density()'.

I think that for a better solution, either
1) the search path should not be used at all to resolve symbols in
packages, or
2) only base packages should be searched.

I realize that this is something that is not easy to change, especially 1)
would break a lot of packages. But maybe at least 'R CMD check' could
report these cases. Currently it reports missing imports for non-base
packages only. Is it reasonable to have a NOTE for missing imports from
base packages as well?

[As usual, please fix me if I am missing or misunderstood something.]

Thank you, Best,
Gabor

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] --interactive and -f/-e

2015-04-28 Thread Mick Jordan
I was surprised by this:

R --interactive -e 'interactive()'

bash-3.2$ R -q -e 'interactive()' --interactive
 > interactive()
[1] FALSE
 >

as the command options document says that --interactive should force 
interactive=TRUE:

" When *R* is run in a terminal (via |Rterm.exe| on Windows), it assumes 
that it is interactive if ‘stdin’ is connected to a (pseudo-)terminal 
and not if ‘stdin’ is redirected to a file or pipe. Command-line options 
--interactive (Unix) and --ess (Windows, |Rterm.exe|) override the 
default assumption"

But the code in system.c does this:

R_Interactive = R_Interactive && (force_interactive || isatty(0));

R_Interactive is set to FALSE in the -e/-f processing, and 
force_interactive is set to TRUE in the --interactive processing, so 
there is no way that it can ever override -e/-f. It seems that 
--interactive can only have an effect for something like a pipe. Is this 
actually the expected behavior?

Mick Jordan




[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel