r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
175 stars 28 forks source link

close #232: fix replacement of parts of units #233

Closed Enchufa2 closed 4 years ago

Enchufa2 commented 4 years ago

With this patch,

x <- set_units(24, h)
x[2] <- set_units(1440, min)
x
#> Units: [h]
#> [1] 24 24

x[2] <- set_units(3, m)
#> Error: cannot convert m into h

h <- data.frame(dt = set_units(24, "h"))
min <- data.frame(dt = set_units(1440, "min"))
rbind(h, min)
#>       dt
#> 1 24 [h]
#> 2 24 [h]
rbind(min, h)
#>           dt
#> 1 1440 [min]
#> 2 1440 [min]
codecov[bot] commented 4 years ago

Codecov Report

Merging #233 into master will increase coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
+ Coverage   94.09%   94.11%   +0.01%     
==========================================
  Files          18       18              
  Lines         898      900       +2     
==========================================
+ Hits          845      847       +2     
  Misses         53       53              
Impacted Files Coverage Δ
R/misc.R 96.66% <100.00%> (+0.11%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ad554d5...4084ffa. Read the comment docs.

edzer commented 4 years ago

Great work!! I looked at the rbind.data.frame code for a long time, but couldn't bring it back to the missing [<- and [[<- problem!