Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread jan Vitek via R-devel
> > I think there's a bit of that flavour here: > > vec_c(factor("a"), Sys.Date()) > #> Error: No common type for factor and date > > This isn't a type system imposed by the language, but I don't think > that's a reason not to call it a type system. All I am saying is that without a clear def

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread luke-tierney
Some ideas from the 'numeric tower' notion in scheme/lisp might also be useful. Best, luke On Thu, 9 Aug 2018, Hadley Wickham wrote: On Thu, Aug 9, 2018 at 4:26 PM jan Vitek wrote: I'm now confident that I can avoid using "type" by itself, and instead always use it in a compound phrase (l

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 4:26 PM jan Vitek wrote: > > > I'm now confident that I > > can avoid using "type" by itself, and instead always use it in a > > compound phrase (like type system) to avoid confusion. That leaves the > > `.type` argument to many vctrs functions. I'm considering change it to

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread jan Vitek via R-devel
> I'm now confident that I > can avoid using "type" by itself, and instead always use it in a > compound phrase (like type system) to avoid confusion. That leaves the > `.type` argument to many vctrs functions. I'm considering change it to > .prototype, because what you actually give it is a zero-l

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
> > As Gabe mentioned (and you've explained about) the term "type" > > is really confusing here. As you know, the R internals are all > > about SEXPs, TYPEOF(), etc, and that's what the R level > > typeof(.) also returns. As you want to use something slightly > > different, it should be different

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 7:54 AM Joris Meys wrote: > > Hi Hadley, > > my point actually came from a data analyst point of view. A character > variable is something used for extra information, eg the "any other ideas?" > field of a questionnaire. A categorical variable is a variable describing > c

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Joris Meys
Hi Hadley, my point actually came from a data analyst point of view. A character variable is something used for extra information, eg the "any other ideas?" field of a questionnaire. A categorical variable is a variable describing categories defined by the researcher. If it is made clear that a fa

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Dirk Eddelbuettel
On 8 August 2018 at 12:40, Hadley Wickham wrote: | I think this is true in the tidyverse, which will never give you a | factor unless you explicitly ask for one, but the default in base R | (at least as soon as a data frame is involved) is to turn character | vectors into factors. False. Base R

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Hadley Wickham
On Thu, Aug 9, 2018 at 3:57 AM Joris Meys wrote: > > I sent this to Iñaki personally by mistake. Thank you for notifying me. > > On Wed, Aug 8, 2018 at 7:53 PM Iñaki Úcar wrote: > > > > > For what it's worth, I always thought about factors as fundamentally > > characters, but with restrictions:

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-09 Thread Joris Meys
I sent this to Iñaki personally by mistake. Thank you for notifying me. On Wed, Aug 8, 2018 at 7:53 PM Iñaki Úcar wrote: > > For what it's worth, I always thought about factors as fundamentally > characters, but with restrictions: a subspace of all possible strings. > And I'd say that a non-ne

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Iñaki Úcar
El mié., 8 ago. 2018 a las 19:23, Gabe Becker () escribió: > > Actually, I sent that too quickly, I should have let it stew a bit more. > I've changed my mind about the resolution argument I Was trying to make. > There is more information, technically speaking, in the factor with empty > levels. I'

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
>> So we say that a >> factor `x` has finer resolution than factor `y` if the levels of `y` >> are contained in `x`. So to find the common type of two factors, we >> take the union of the levels of each factor, given a factor that has >> finer resolution than both. > > I'm not so sure. I think a mo

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
> > I now have a better argument, I think: > > > If you squint your brain a little, I think you can see > > that each set of automatic coercions is about increasing > > resolution. Integers are low resolution versions of > > doubles, and dates are low resolution versions of >

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Gabe Becker
Actually, I sent that too quickly, I should have let it stew a bit more. I've changed my mind about the resolution argument I Was trying to make. There is more information, technically speaking, in the factor with empty levels. I'm still not convinced that its the right behavior, personally. It may

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Gabe Becker
Hadley, Responses inline. On Wed, Aug 8, 2018 at 7:34 AM, Hadley Wickham wrote: > >>> Method dispatch for `vec_c()` is quite simple because associativity and > >>> commutativity mean that we can determine the output type only by > >>> considering a pair of inputs at a time. To this end, vctrs p

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Martin Maechler
> Hadley Wickham > on Wed, 8 Aug 2018 09:34:42 -0500 writes: Method dispatch for `vec_c()` is quite simple because associativity and commutativity mean that we can determine the output type only by considering a pair of inputs at a time. To this end

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-08 Thread Hadley Wickham
>>> Method dispatch for `vec_c()` is quite simple because associativity and >>> commutativity mean that we can determine the output type only by >>> considering a pair of inputs at a time. To this end, vctrs provides >>> `vec_type2()` which takes two inputs and returns their common type >>> (repres

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-06 Thread Hadley Wickham
> First off, you are using the word "type" throughout this email; You seem to > mean class (judging by your Date and factor examples, and the fact you > mention S3 dispatch) as opposed to type in the sense of what is returned by > R's typeof() function. I think it would be clearer if you called it

Re: [Rd] vctrs: a type system for the tidyverse

2018-08-06 Thread Gabe Becker
Hadley, Looks interesting and like a fun project from what you said in the email (I don't have time right now to dig deep into the readme) A few thoughts. First off, you are using the word "type" throughout this email; You seem to mean class (judging by your Date and factor examples, and the fact

[Rd] vctrs: a type system for the tidyverse

2018-08-06 Thread Hadley Wickham
Hi all, I wanted to share with you an experimental package that I’m currently working on: vctrs, . The motivation for vctrs is to think deeply about the output “type” of functions like `c()`, `ifelse()`, and `rbind()`, with an eye to implementing one strategy throug