Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Abby Spurdle
Herve Pages wrote: > In my experience, and more generally speaking, the desire to treat > 0-length vectors as a special case that deviates from the > non-zero-length case has never been productive. Good idea. Gabriel Becker Wrote: > > nrow(rbind(aa = c("a", "b", "c"), AA = character())) > [1] 1

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Jan Gorecki
Hi Gabriel > Personally, no I wouldn't. I would consider m==0 a degenerate case, where there is no data, but I personally find matrices (or data.frames) with rows but no columns a very strange concept. This distinction between matrix and data.frames is the crux in this case. >From the dimensional

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Pages, Herve
On 5/16/19 17:48, Gabriel Becker wrote: Hi Herve, Inline. On Thu, May 16, 2019 at 4:45 PM Pages, Herve mailto:hpa...@fredhutch.org>> wrote: Hi Gabe, ncol(data.frame(aa=c("a", "b", "c"), AA=c("A", "B", "C"))) # [1] 2 ncol(data.frame(aa="a", AA="A")) # [1] 2 ncol(data.frame(aa

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Gabriel Becker
Hi Herve, Inline. On Thu, May 16, 2019 at 4:45 PM Pages, Herve wrote: > Hi Gabe, > >ncol(data.frame(aa=c("a", "b", "c"), AA=c("A", "B", "C"))) ># [1] 2 > >ncol(data.frame(aa="a", AA="A")) ># [1] 2 > >ncol(data.frame(aa=character(0), AA=character(0))) ># [1] 2 > >nc

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Pages, Herve
Hi Gabe,   ncol(data.frame(aa=c("a", "b", "c"), AA=c("A", "B", "C")))   # [1] 2   ncol(data.frame(aa="a", AA="A"))   # [1] 2   ncol(data.frame(aa=character(0), AA=character(0)))   # [1] 2   ncol(cbind(aa=c("a", "b", "c"), AA=c("A", "B", "C")))   # [1] 2   ncol(cbind(aa="a", AA="A"))

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Gabriel Becker
On Thu, May 16, 2019 at 3:47 PM Gabriel Becker wrote: > Hi Hadley, > > Thanks for the counterpoint. Response below. > > On Thu, May 16, 2019 at 1:59 PM Hadley Wickham > wrote: > >> The existing behaviour seems inutitive to me. I would consider these >> invariants for n vector x_i's each with siz

Re: [Rd] ALTREP: Bug reports

2019-05-16 Thread Gabriel Becker
Jiefei, Inline. On Thu, May 16, 2019 at 2:30 PM 介非王 wrote: > Hello Luke and Gabriel, > > Thank you very much for your quick responses. The explanation of STDVEC is > very helpful and I appreciate it! For the wrapper, I have a few new > questions. > > > 1. Like Luke said a mutable object is not

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Gabriel Becker
Hi Hadley, Thanks for the counterpoint. Response below. On Thu, May 16, 2019 at 1:59 PM Hadley Wickham wrote: > The existing behaviour seems inutitive to me. I would consider these > invariants for n vector x_i's each with size m: > > * nrow(rbind(x_1, x_2, ..., x_n)) equals n > Personally, no

Re: [Rd] ALTREP: Bug reports

2019-05-16 Thread 介非王
Hi, Sorry for overflow the mailbox. Please ignore the second question, I misunderstand Gabriel answer. Best, Jiefei On Thu, May 16, 2019 at 5:29 PM 介非王 wrote: > Hello Luke and Gabriel, > > Thank you very much for your quick responses. The explanation of STDVEC is > very helpful and I appreciat

Re: [Rd] ALTREP: Bug reports

2019-05-16 Thread 介非王
Hello Luke and Gabriel, Thank you very much for your quick responses. The explanation of STDVEC is very helpful and I appreciate it! For the wrapper, I have a few new questions. 1. Like Luke said a mutable object is not possible. However, I noticed that there is one extra argument *deep* in the

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread robin hankin
Gabriel, you ask an insightful and instructive question. One of R's great strengths is that we have a forum where this kind of edge-case can be fruitfully discussed. My interest in this would be the names of the arguments; in the magic package I make heavy use of the dimnames of zero-extent arrays.

Re: [Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Hadley Wickham
The existing behaviour seems inutitive to me. I would consider these invariants for n vector x_i's each with size m: * nrow(rbind(x_1, x_2, ..., x_n)) equals n * ncol(rbind(x_1, x_2, ..., x_n)) equals m Additionally, wouldn't you expect rbind(x_1[i], x_2[i]) to equal rbind(x_1, x_2)[, i, drop = F

[Rd] nrow(rbind(character(), character())) returns 2 (as documented but very unintuitive, IMHO)

2019-05-16 Thread Gabriel Becker
Hi all, Apologies if this has been asked before (a quick google didn't find it for me),and I know this is a case of behaving as documented but its so unintuitive (to me at least) that I figured I'd bring it up here anyway. I figure its probably going to not be changed, but I'm happy to submit a

Re: [Rd] ALTREP: Bug reports

2019-05-16 Thread Gabriel Becker
Hi Jiefei, Thanks for tryingout the ALTREP stuff and letting us know how it is going. That said I don't think either of these are bugs, per se, but rather a misunderstanding of the API. Details inline. On Thu, May 16, 2019 at 11:57 AM 介非王 wrote: > Hello, > > I have encountered two bugs when u

Re: [Rd] [External] ALTREP: Bug reports

2019-05-16 Thread Tierney, Luke
On Thu, 16 May 2019, 介非王 wrote: > Hello, > > I have encountered two bugs when using ALTREP APIs. > > 1. STDVEC_DATAPTR > > From RInternal.h file it has a comment: > > /* ALTREP support */ >> void *(STDVEC_DATAPTR)(SEXP x); > > > However, this comment might not be true, the easiest way to verify it

[Rd] ALTREP: Bug reports

2019-05-16 Thread 介非王
Hello, I have encountered two bugs when using ALTREP APIs. 1. STDVEC_DATAPTR >From RInternal.h file it has a comment: /* ALTREP support */ > void *(STDVEC_DATAPTR)(SEXP x); However, this comment might not be true, the easiest way to verify it is to define a C++ function: void C_testFunc(SEX

[Rd] print.() not called when autoprinting

2019-05-16 Thread William Dunlap via R-devel
In R-3.6.0 autoprinting was changed so that print methods for the storage modes are not called when there is no explicit class attribute. E.g., % R-3.6.0 --vanilla --quiet > print.function <- function(x, ...) { cat("Function with argument list "); cat(sep="\n", head(deparse(args(x)), -1)); i