Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Tomas Kalibera
On 05/03/2018 11:14 PM, Henrik Bengtsson wrote: Also, as mentioned in my https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html, when not specifying the mode argument, the default on Windows is mode = "w" *except* for certain, case-sensitive, filename extensions: if(missing(mode) &&

Re: [Rd] Proposed speedup of ifelse

2018-05-03 Thread Hugh Parsonage
Thanks Radford. I concur with all your points. I've attempted to address the issues you raised through the github.io post. The new method appears to be slower for test lengths < 100 and possibly longer lengths (not just < 10). Of course length(test) < 100 is very quick, so I simply added this to t

Re: [Rd] length of `...`

2018-05-03 Thread Michel Lang
FWIW, there is also a backport of `...length()` for R versions >3.0.0 in my package backports (shameless self promotion): . 2018-05-03 19:41 GMT+02:00 peter dalgaard : > > >> On 3 May 2018, at 19:23 , Hadley Wickham wrote: >> >> Maybe just get(paste0("..", n))

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Henrik Bengtsson
Also, as mentioned in my https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html, when not specifying the mode argument, the default on Windows is mode = "w" *except* for certain, case-sensitive, filename extensions: if(missing(mode) && length(grep("\\.(gz|bz2|xz|tgz|zip|rda|RData)$", u

Re: [Rd] length of `...`

2018-05-03 Thread peter dalgaard
> On 3 May 2018, at 19:23 , Hadley Wickham wrote: > > Maybe just get(paste0("..", n)) ? > > Hadley Maybe not. These things are slippery. > f <- function(...) get("..1") > f(2) Error in get("..1") : object '..1' not found -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Busin

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 9:50 AM, Duncan Murdoch wrote: > On 03/05/2018 11:18 AM, Duncan Murdoch wrote: >> >> On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >>> >>> In R-3.5.0 you can use ...length(): >>> > f <- function(..., n) ...length() >>> > f(stop("one"), stop("two"), stop("

Re: [Rd] length of `...`

2018-05-03 Thread Duncan Murdoch
On 03/05/2018 11:18 AM, Duncan Murdoch wrote: On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g

Re: [Rd] length of `...`

2018-05-03 Thread Hervé Pagès
Hi, It would be great if one of the experts could comment on the difference between Hadley's dotlength and ...length? The fact that someone bothered to implement a new primitive for that when there seems to be a very simple and straightforward R-only solution suggests that there might be some got

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:28 AM, Hadley Wickham wrote: > On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: >> As of 3.5.0 the ...length() function does exactly what you are asking for. >> Before that, I don't know of an easy way to get the length without >> evaluation via R code. There may be one

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:18 AM, Duncan Murdoch wrote: > On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >> >> In R-3.5.0 you can use ...length(): >>> f <- function(..., n) ...length() >>> f(stop("one"), stop("two"), stop("three"), n=7) >>[1] 3 >> >> Prior to that substitute()

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: > As of 3.5.0 the ...length() function does exactly what you are asking for. > Before that, I don't know of an easy way to get the length without > evaluation via R code. There may be one I'm not thinking of though, I > haven't needed to do this m

Re: [Rd] length of `...`

2018-05-03 Thread Martin Morgan
nargs() provides the number of arguments without evaluating them > f = function(x, ..., y) nargs() > f() [1] 0 > f(a=1, b=2) [1] 2 > f(1, a=1, b=2) [1] 3 > f(x=1, a=1, b=2) [1] 3 > f(stop()) [1] 1 On 05/03/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length():

Re: [Rd] length of `...`

2018-05-03 Thread peter dalgaard
> On 3 May 2018, at 16:52 , Mark van der Loo wrote: > > This question is better aimed at the r-help mailinglist as it is not about > developing R itself. Um, no... People there might well send you back here. As for the original question, there are also variations over dddlen <- function(...)

Re: [Rd] length of `...`

2018-05-03 Thread Duncan Murdoch
On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g <- function(..., n) length(substitute(...())) >

Re: [Rd] length of `...`

2018-05-03 Thread Tóth Dénes
Thank you Bill (and the R-Core Team), this is even more than what I thought of. I somehow missed this in the NEWS. BTW, substitue(...()) is beautiful. On 05/03/2018 05:01 PM, William Dunlap wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), s

Re: [Rd] length of `...`

2018-05-03 Thread Gabe Becker
As of 3.5.0 the ...length() function does exactly what you are asking for. Before that, I don't know of an easy way to get the length without evaluation via R code. There may be one I'm not thinking of though, I haven't needed to do this myself. Hope that helps. ~G On Thu, May 3, 2018 at 7:52 AM

Re: [Rd] length of `...`

2018-05-03 Thread William Dunlap via R-devel
In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g <- function(..., n) length(substitute(...())) > g(stop("one"), stop("two"), stop("three"), n=7) [1] 3 R-3.5.0

Re: [Rd] Proposed speedup of ifelse

2018-05-03 Thread Radford Neal
> I propose a patch to ifelse that leverages anyNA(test) to achieve an > improvement in performance. For a test vector of length 10, the change > nearly halves the time taken and for a test of length 1 million, there > is a tenfold increase in speed. Even for small vectors, the > distributions of t

Re: [Rd] length of `...`

2018-05-03 Thread Mark van der Loo
This question is better aimed at the r-help mailinglist as it is not about developing R itself. having said that, I can only gues why you want to do this, but why not do something like this: f <- function(...){ L <- list(...) len <- length() # you can stll pass the ... as follows: do

[Rd] length of `...`

2018-05-03 Thread Dénes Tóth
Hi, In some cases the number of arguments passed as ... must be determined inside a function, without evaluating the arguments themselves. I use the following construct: dotlength <- function(...) length(substitute(expression(...))) - 1L # Usage (returns 3): dotlength(1, 4, something = unde

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Joris Meys
Thank you Henrik and Martin for explaining what was going on. Very insightful! On Thu, May 3, 2018 at 4:21 PM, Jeroen Ooms wrote: > On Thu, May 3, 2018 at 2:42 PM, Henrik Bengtsson > wrote: > > Use mode="wb" when you download the file. See > > https://github.com/HenrikBengtsson/Wishlist-for-R/i

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Jeroen Ooms
On Thu, May 3, 2018 at 2:42 PM, Henrik Bengtsson wrote: > Use mode="wb" when you download the file. See > https://github.com/HenrikBengtsson/Wishlist-for-R/issues/30. > > R core, and others, is there a good argument for why we are not making this > the default download mode? It seems like a such a

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Martin Morgan
On 05/03/2018 05:48 AM, Joris Meys wrote: Dear all, I've been diving a bit deeper into this per request of Tomas Kalibra, and found the following : - the lock on the file is only after trying to read it using oligo, so that's not a R problem in itself. The problem is independent of extrenal pa

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Duncan Murdoch
On 03/05/2018 8:42 AM, Henrik Bengtsson wrote: Use mode="wb" when you download the file. See https://github.com/HenrikBengtsson/Wishlist-for-R/issues/30. R core, and others, is there a good argument for why we are not making this the default download mode? It seems like a such a simple fix to su

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Joris Meys
Dear all, I've been diving a bit deeper into this per request of Tomas Kalibra, and found the following : - the lock on the file is only after trying to read it using oligo, so that's not a R problem in itself. The problem is independent of extrenal packages. - using Windows' fc utility and cygw

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Martin Morgan
On 05/02/2018 03:21 PM, Joris Meys wrote: Dear all, I've noticed by trying to download gz files from here : https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM907811 At the bottom one can download GSM907811.CEL.gz . If I download this manually and try oligo::read.celfiles("GSM907811.CEL.g

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Joris Meys
Using the correct mode absolutely solves it. Apologies for not trying the obvious. Cheers Joris On Thu, May 3, 2018 at 2:10 PM, Martin Morgan wrote: > > > On 05/02/2018 03:21 PM, Joris Meys wrote: > >> Dear all, >> >> I've noticed by trying to download gz files from here : >> https://www.ncbi.n

Re: [Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Henrik Bengtsson
Use mode="wb" when you download the file. See https://github.com/HenrikBengtsson/Wishlist-for-R/issues/30. R core, and others, is there a good argument for why we are not making this the default download mode? It seems like a such a simple fix to such a common "mistake". Henrik On Thu, May 3, 20

[Rd] download.file does not process gz files correctly (truncates them?)

2018-05-03 Thread Joris Meys
Dear all, I've noticed by trying to download gz files from here : https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM907811 At the bottom one can download GSM907811.CEL.gz . If I download this manually and try oligo::read.celfiles("GSM907811.CEL.gz") everything works fine. (oligo is a bioCon