-
Notifications
You must be signed in to change notification settings - Fork 993
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
forward operations to vectorised attributes #2948
Labels
non-atomic column
e.g. list columns, S4 vector columns
Comments
could you please rerun the subset with verbose = TRUE and include the
output?
…On Fri, Jun 22, 2018, 2:17 AM Iñaki Ucar ***@***.***> wrote:
The units package stores unit metadata for vectors and arrays as an
attribute, and it seems to work fine with data.table:
library(data.table)
library(units)#> udunits system database from /usr/share/udunits
(DT <- data.table(x = set_units(1:5, m), y = set_units(2, s)))#> x y#> 1: 1 m 2 s#> 2: 2 m 2 s#> 3: 3 m 2 s#> 4: 4 m 2 s#> 5: 5 m 2 sDT[, z := x/y]DT#> x y z#> 1: 1 m 2 s 0.5 m/s#> 2: 2 m 2 s 1.0 m/s#> 3: 3 m 2 s 1.5 m/s#> 4: 4 m 2 s 2.0 m/s#> 5: 5 m 2 s 2.5 m/sDT[x > set_units(3, m)]#> x y z#> 1: 4 m 2 s 2.0 m/s#> 2: 5 m 2 s 2.5 m/s
Similarly, the errors package stores uncertainty metadata for vectors and
arrays, but this time the attribute is a vector of errors. Some operations
are correctly forwarded:
library(errors)
(DT <- data.table(x = set_errors(1:5, 1:5/10), y = set_errors(2, 0.1)))#> x y#> 1: 1.0(1) 2.0(1)#> 2: 2.0(2) 2.0(1)#> 3: 3.0(3) 2.0(1)#> 4: 4.0(4) 2.0(1)#> 5: 5.0(5) 2.0(1)DT[, z := x/y]DT#> x y z#> 1: 1.0(1) 2.0(1) 0.50(6)#> 2: 2.0(2) 2.0(1) 1.0(1)#> 3: 3.0(3) 2.0(1) 1.5(2)#> 4: 4.0(4) 2.0(1) 2.0(2)#> 5: 5.0(5) 2.0(1) 2.5(3)
As you can see above, errors are propagated for the division. But others
not:
DT.subset <- DT[x > set_errors(3)]#> Warning: In '>' : boolean operators not defined for 'errors' objects,#> errors dropped#> Warning in exponent + value_digits: longer object length is not a multiple#> of shorter object length#> Warning in (scientific | (exponent > 4 + scipen | exponent < -3 - scipen))#> & : longer object length is not a multiple of shorter object length#> Warning in exponent + value_digits: longer object length is not a multiple#> of shorter object length#> Warning in (scientific | (exponent > 4 + scipen | exponent < -3 - scipen))#> & : longer object length is not a multiple of shorter object length#> Warning in exponent + value_digits: longer object length is not a multiple#> of shorter object length#> Warning in (scientific | (exponent > 4 + scipen | exponent < -3 - scipen))#> & : longer object length is not a multiple of shorter object length#> Error in dimnames(x) <- dn: length of 'dimnames' [1] not equal to array extent
The errors class does implement the subsetting operator, but it's not
getting called, so the resulting errors object is corrupted (more errors
than values):
DT$x#> Errors: 0.1 0.2 0.3 0.4 0.5#> [1] 1 2 3 4 5DT.subset$x#> Errors: 0.1 0.2 0.3 0.4 0.5#> [1] 4 5
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2948>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHQQdYur7XrXqG3X7ln4QrKdbX_S6Vjrks5t--M_gaJpZM4UyiyI>
.
|
There's no additional output with |
jangorecki
changed the title
Feature request: forward operations to vectorised attributes
forward operations to vectorised attributes
Apr 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
units
package stores unit metadata for vectors and arrays as an attribute, and it seems to work fine withdata.table
:Similarly, the
errors
package stores uncertainty metadata for vectors and arrays, but this time the attribute is a vector of errors. Some operations are correctly forwarded:As you can see above, errors are propagated for the division. But others not:
The
errors
class does implement the subsetting operator, but it's not getting called, so the resultingerrors
object is corrupted (more errors than values):The text was updated successfully, but these errors were encountered: