Using dplyr functions on grouped data frame with variable of class difftime generates error #390
I illustrate this using some toy data with a grouping variable (grp), a column with some values (val), two date columns (date1, date2), and a variable of class
I tried to add the mean of vals within each group to the original data set. The desired output can be created using
When I try to create the same output with
Just to check, the same error is generated when the
...or when using (toy examples of)
...or on an ungrouped 'tbl_df':
Neither does the
My current quick and dirty workaround is to convert the
However, there are quite a few methods for the
Search on SO and google for 'dplyr difftime "Error in eval(expr, envir, enclos)" : column has unsupported type' gave no hits.
Thanks a lot for your great work with a fantastic package.
The text was updated successfully, but these errors were encountered:
What we do is check for attributes:
We don't know how to handle the
This just bit me too. Where's the relevant code for the current special case? Surely that could be made more generic based on the class of the column...
Oh, is it "all over the place" and in C++.
The really annoying thing is that dplyr complains even if you don't use that column in your chain.
My workaround is to use transform, eg:
transform(mdmh, ahead=as.numeric(ahead)) %.% group_by(etc) %.% etc
What's strange is that when I tried to provide a reproducible example, the error disappeared.
If my df is ntstrips,
Then do this:
I came across a maybe confusing behaviour with dplyr and difftime. Using the example given above:
When I (wrongly ! ) try to use
If i do not include the