-
Notifications
You must be signed in to change notification settings - Fork 66
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
"Some attributes are incompatible" error #1130
Comments
Actually, it doesn't work for {units} either with different but compatible units: c(set_units(1, km), set_units(3, m))
#> Units: [km]
#> [1] 1.000 0.003
vctrs::vec_ptype_common(set_units(1, km), set_units(3, m))
#> Error: Can't combine `..1` <units> and `..2` <units>.
#> x Some attributes are incompatible.
#> ℹ The author of the class should implement vctrs methods.
#> ℹ See <https://vctrs.r-lib.org/reference/faq-error-incompatible-attributes.html>. |
(@Enchufa2 apologies for the hassle this has cause — somehow we didn't see this in our revdep checks, and then CRAN accepted the package surprisingly quickly. We're working hard to resolve as many of the problems as possible from our end) |
@Enchufa2 I think we'll need to implement vctrs methods for units, errors, and perhaps quantities. I'm now studying your packages and will start working on PRs tomorrow. |
Very much appreciated. I would have started it myself, but I have my hands full with other duties. |
I read the FAQs and started something here, but clearly I don't know what I'm doing, and library(errors)
library(dplyr, warn.conflicts=FALSE)
iris.q <- iris
for (i in 1:4)
errors(iris.q[,i]) <- iris.q[,i] * 0.05
iris.q %>%
group_by(Species) %>%
summarise_all(mean)
#> # A tibble: 3 x 5
#> Species Sepal.Length Sepal.Width Petal.Length Petal.Width
#> <fct> <[(err)]> <[(err)]> <[(err)]> <[(err)]>
#> 1 setosa 5.006(NA) 3.428(NA) 1.462(NA) 0.246(NA)
#> 2 versicolor 5.936(NA) 2.77(NA) 4.26(NA) 1.326(NA)
#> 3 virginica 6.588(NA) 2.974(NA) 5.552(NA) 2.026(NA) |
Right, this class also needs to implement In the A proxy is simply the internal data representation for your class, and with a data frame proxy you're saying that each element is defined by the data contained in multiple columns, row by row. The At the same time, the errors are not used for comparison and identity, and so they shouldn't be part of the equality proxy, which needs to be overidden ( Here is my work in progress: r-quantities/errors@master...lionel-:add-vctrs. I'm happy to finish this and send a PR, but let me know if you'd like to pick this up. |
Makes sense. I was afraid I had to basically duplicate every single base method implemented for the class into its But step by step. I think that, with a working reference implementation for {errors}, things will be much clearer for me, so I'd appreciate it very much if you can finish that PR. Could you please rebase your current work using the |
Yes for quantities I think we'll be in maturing/experimental territory. It's linked to #945. We'd like to make this part of vctrs more robust for 0.4.0, and your classes seem like a good use case for us. |
Great. I bought some time by sending a quick patch for {quantities} to CRAN to prevent WARNs in vignettes. |
@Enchufa2 Would you like to have integration tests with dplyr in your packages? To do this, we can either add dplyr to Suggests, or use the same strategy I use for sf if you prefer to avoid the soft dependency: vctrs/tests/testthat/test-type-sf.R Lines 2 to 13 in 29baab9
In the latter case the tests are only run when the machine happens to have dplyr installed (usually, your local machine). The main advantage of adding to Suggests is that you'll be included in our revdep checks. The disadvantage is that it might slow down your CI builds a bit. Though dplyr is now a much lighter dependency than it used to. |
Yes, and ok to add it to Suggests. But in that case there should be a |
I has been notified that the {quantities} package has a broken vignette on CRAN. This is the error:
How are groups with the same class incompatible? I tracked down the issue a little bit. A {quantities} object has two parts: {units} and {errors}. Just with {units}, it works ok:
But not with {errors}:
I continued tracking the issue down to
vec_ptype_common
, which works for {units}:but not for {errors}:
We are going to implement glue for {vctrs}, as we discussed in r-quantities/units#239, but shouldn't this work? And if so, it would be great if the fix makes it into the planned patch release, so that I don't have to apply a quick workaround to retain {quantities} on CRAN.
The text was updated successfully, but these errors were encountered: