Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Is there any advantage/disadvantage to the
> (y <- lubridate::year(as.Date("2012-05-09")))  2012 > class(y)  "numeric"
It's certainly not a real problem, but I've noticed that I almost always wrap it in
The same applies to other accessors, except
So the extent of the change is non-trivial and is likely to cause S4 related breakage internally and for dependent packages. Why did you propose the change in the first place? What's your usage pattern?
Also note that the fix shouldn't be with
Thanks for the explanations, @vspinu.
Ok. It may not make sense, but I thought I'd suggest it anyway. I assumed that it wouldn't cause numerical problems because the 32-bit integer would always be implicitly cast to the 64-bit float by R. But maybe I'm missing something, or maybe there's an S4 type problem that I'm unaware of.
Because I use year a lot as a grouping variable or in other scenarios where I'm reluctant to use a floating point value in numerical comparisons. And I write a lot to databases, and the smaller data type makes things a tad more efficient. I guess it's a left over from my OO days, and using the most specific data type possible.
Also, I'm not aware of a scenario where I'd want 'year()' to validly return a non-integer. But I certainly could be overlooking an important use case.
Cool. Makes sense.
Cool. I wasn't aware of that. Maybe that's another argument