[Rd] The case for a pipe assignment operator + database of R code

2023-12-29 Thread David Hugh-Jones
Hi all, I wrote up the case for having a pipe assignment operator in R here: https://hughjonesd.github.io/case-for-pipe-assignment.html A pipe assignment operator would expand e.g. obj <|> do_something() to obj <- obj |> do_something() and therefore to obj <- do_something(obj) Just for fun,

Re: [Rd] anonymous functions

2020-12-07 Thread David Hugh-Jones
I will stick my oar in here as a user to say that I find the \(x) syntax a bit line-noise-ish. David > On 8 Dec 2020, at 00:05, Abby Spurdle wrote: > > Sorry, I should replace "cryptic-ness" from my last post, with > "unnecessary cryptic-ness". > Sometimes short symbolic expressions are nece

Re: [Rd] should base R have a piping operator ?

2019-10-05 Thread David Hugh-Jones
I +1 this idea, without judging the implementation details. The pipe operator has proven vastly popular. Adding it would be relatively easy (I think). Having it as part of the core would be a strong guarantee of the future stability of this syntax. On Sat, 5 Oct 2019 at 15:34, Ant F wrote: > D

Re: [Rd] New grDevices::hcl.colors()

2019-04-02 Thread David Hugh-Jones
Hi Achim Quick Q: why do some palettes have a hyphen in the name and others not? David On Tue, 2 Apr 2019 at 00:38, Achim Zeileis wrote: > Hi everyone, > > I wanted to draw your attention to a new post on the > developer.R-project.org blog: > > https://developer.R-project.org/Blog/public/2019/

[Rd] Possible bug in requireNamespace

2019-03-14 Thread David Hugh-Jones
At least, unexpected behaviour. The documentation says: quietly: logical: should progress and error messages be suppressed? But if you do e.g. requireNamespace("broom", quietly = TRUE) requireNamespace("broom.mixed", quietly = TRUE) You will get messages when broom.mixed overrides broom's meth

Re: [Rd] Documentation examples for lm and glm

2018-12-14 Thread David Hugh-Jones
I would argue examples should encourage good practice. Beginners ought to learn to keep data in data frames and not to overuse attach(). Experts can do otherwise at their own risk, but they have less need of explicit examples. On Fri, 14 Dec 2018 at 14:51, S Ellison wrote: > FWIW, before all the

[Rd] small bug in formatC?

2018-10-25 Thread David Hugh-Jones
formatC(0.0001, digits = 3, format = "f", zero.print="< 0.01") Error in strrep(" ", nc - i1) : invalid 'times' value The problem, if it is one, is in .format.zeros: .format.zeros("0.000", "xx") Error in strrep(" ", nc - i1) : invalid 'times' value R version 3.5.1. David [[alternati

Re: [Rd] Bias in R's random integers?

2018-09-19 Thread David Hugh-Jones
It doesn't seem too hard to come up with plausible ways in which this could give bad results. Suppose I sample rows from a large dataset, maybe for bootstrapping. Suppose the rows are non-randomly ordered, e.g. odd rows are males, even rows are females. Oops! Very non-representative sample, bootstr

Re: [Rd] Bias in R's random integers?

2018-09-19 Thread David Hugh-Jones
On Wed, 19 Sep 2018 at 13:43, Duncan Murdoch wrote: > > I think the analyses are correct, but I doubt if a change to the default > is likely to be accepted as it would make it more difficult to reproduce > older results. I'm a bit alarmed by the logic here. Unbiased sampling seems basic for a s

Re: [Rd] Puzzle or bug with matrix indexing

2018-08-04 Thread David Hugh-Jones
Yup, I worked it out in time... for future reference, as.matrix calls `format` on logicals, converting them to the form seen. On Sat, 4 Aug 2018 at 17:53, Berry, Charles wrote: > > > > On Aug 4, 2018, at 6:55 AM, David Hugh-Jones > wrote: > > > > I'm not sure wh

[Rd] Puzzle or bug with matrix indexing

2018-08-04 Thread David Hugh-Jones
I'm not sure why this is happening: tmp <- data.frame( a = letters[1:2], b=c(TRUE, FALSE), stringsAsFactors = FALSE ) idx <- matrix(c(1, 2, 2, 2), 2, byrow = TRUE) tmp[idx] [1] " TRUE" "FALSE" Notice there is a space before the TRUE: " TRUE". This space isn't happening purely because of c

Re: [Rd] Fwd: help building very old R

2018-07-30 Thread David Hugh-Jones
Thanks for the tip. That could be a huge timesaver. But it lists only a single package for versions 0.90.1-2 ... how does that work? David On Mon, 30 Jul 2018 at 12:27, Dirk Eddelbuettel wrote: > > On 30 July 2018 at 05:35, David Hugh-Jones wrote: > | Hi guys, > | > | Perhaps s

Re: [Rd] apply with zero-row matrix

2018-07-30 Thread David Hugh-Jones
Jul 2018 at 15:05, Gabor Grothendieck wrote: > Try pmap and related functions in purrr: > > pmap(as.data.frame(m), ~ { cat("Called...\n"); print(c(...)) }) > ## list() > > On Mon, Jul 30, 2018 at 12:33 AM, David Hugh-Jones > wrote: > > Forgive me if this

Re: [Rd] apply with zero-row matrix

2018-07-30 Thread David Hugh-Jones
(presumably NULL) for an empty argument; but why should apply call fun? Cheers David On Mon, 30 Jul 2018 at 08:41, Martin Maechler wrote: > >>>>> David Hugh-Jones > >>>>> on Mon, 30 Jul 2018 05:33:19 +0100 writes: > > > Forgive me if this has been as

[Rd] Fwd: help building very old R

2018-07-29 Thread David Hugh-Jones
Hi guys, Perhaps someone here can help. I am trying to build versions of R 1 for the rcheology package (just arrived on CRAN). For R prior to 1.5.0, I cannot configure support for tcl-tk. I am building on Debian Woody (provided by Docker debian/eol) and have the following packages installed: r-

[Rd] apply with zero-row matrix

2018-07-29 Thread David Hugh-Jones
Forgive me if this has been asked many times before, but I couldn't find anything on the mailing lists. I'd expect apply(m, 1, foo) not to call `foo` if m is a matrix with zero rows. In fact: m <- matrix(NA, 0, 5) apply(m, 1, function (x) {cat("Called...\n"); print(x)}) ## Called... ## [1] FALSE

Re: [Rd] cat(fill=N)

2018-03-16 Thread David Hugh-Jones
t;. But I think the behaviour I expected is more intuitive. The natural use case is to limit line length, and if so, that should apply globally not just between elements. On 16 March 2018 at 16:19, Serguei Sokol wrote: > Le 16/03/2018 à 17:10, David Hugh-Jones a écrit : > >> Hi

[Rd] cat(fill=N)

2018-03-16 Thread David Hugh-Jones
Hi all, I expect I'm getting something wrong, but cat("foo bar baz foo bar baz foo bar baz", fill = 10) should be broken into lines of width 10, whereas I get: > cat("foo bar baz foo bar baz foo bar baz", fill = 10) foo bar baz foo bar baz foo bar baz This is on R 3.4.3, but I don't see menti

[Rd] speeding up R compilation

2018-03-15 Thread David Hugh-Jones
Hello all, First, a small advert for this: https://hughjonesd.shinyapps.io/rcheology/ which lists functions in core R going back to 3.0.1. Second, I'm trying to extend this back to 2.0.0. That involves building many versions of R from source on a Docker image of Debian Sarge. (Shades of 2006, wh

[Rd] Fwd: install.packages doesn't produce warnings unless qualified with utils::

2018-03-04 Thread David Hugh-Jones
On Sat, 3 Mar 2018 at 20:01, Joshua Ulrich wrote: > > > > My guess is that something (a package, console, etc) is masking > utils::install.packages(). > > This looks about right. On R in the terminal the warning is thrown. In Rstudio I have the problem, and: > getAnywhere('install.packages') 2

[Rd] install.packages doesn't produce warnings unless qualified with utils::

2018-03-03 Thread David Hugh-Jones
Hi all, Assuming this is an R core issue: tryCatch(install.packages("clipr", repos = "bullshit"), warning = function (w) cat("got a warning")) Warning in install.packages : unable to access index for repository bullshit/src/contrib: cannot open URL 'bullshit/src/contrib/PACKAGES' Warning in i

Re: [Rd] PR#6614

2006-02-27 Thread David Hugh-Jones
One thing I notice is that after using subset() on a data frame imported from SPSS, my variable.names attribute disappeared. I guess what I would expect is for a subset() method always to preserve everything but the omitted column. Cheers David On 27/02/06, Bill Dunlap <[EMAIL PROTECTED]> wrote: