-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
combining mean
with reformatted Date
class and by
throwing an error
#1876
Comments
pushing aside statistical issue of "what does the 'average date' mean? why not on a machine so can only suggest to try and replicate the issue in one On Oct 13, 2016 6:11 AM, "Ross Holmberg" notifications@github.com wrote:
|
The OP's question on SO: http://stackoverflow.com/questions/40011525/data-table-not-accepting-by-and-format-for-date-at-the-same-time It does seem like a bug. On the other hand, it also seems that what you are attempting is not a good idea. If two sessions both have a majority of their dates in the same month, they will end up, you won't be able to use this as a label. |
Thanks Michael and Frank. @MichaelChirico I've done a couple of tests, and other comparable methods seem to work fine. Starting from the same data as above, just with
Both of the above methods work fine. I know they're not technically "one line", but the calculation of mean date and format conversion are being done in one step in both cases. @franknarf1 you're right, my method here could be different (the situation you mention should never happen here, but importantly this labelling system was decided upon by someone else), and that's why I was happy to accept the working solution offered on SO. That solution was simply to avoid using |
well, there's probably your issue! (?) I imagine data.table's own internal, optimized mean function is being On Oct 14, 2016 5:19 AM, "Ross Holmberg" notifications@github.com wrote:
|
@MichaelChirico Oh, that might be it, but the details aren't clear to me. GForce only kicks in for the vanilla |
According to the error, "invalid 'trim' argument", I think According to In other words, I think that the method used by |
I've come across an issue using a formatted date column with
by
. Take the following data:I want to mark each session with a label, formatted
%b-%Y
, based on the mean date for that session.I can find the mean date of each session, using the
by
parameter:I can also reformat a mean date the way I want within
data.table
:But I can't do both:
The above returns an error:
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid 'trim' argument In addition: Warning message: In mean(date) : argument is not numeric or logical: returning NA
Note I can do what I need in two steps (below), and it works OK, but there does seem to be something going wrong with the above :
It also works fine with
mean.Date
:The text was updated successfully, but these errors were encountered: