Code Monkey home page Code Monkey logo

Comments (2)

orichters avatar orichters commented on September 2, 2024

Noticed this as well. Would be great if that was fixed, at least with the option only.new = TRUE. Maybe @0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q can have look, would be appreciated.

from quitte.

0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q avatar 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q commented on September 2, 2024

Is this intended or a bug?

calc_addVariable() reimplements calcAddVariabe(). It didn't work there, so it doesn't work here.

I would actually like the function to overwrite the old variable by the newly calculated one. Unit conversions would be a classic application of this functionality.

It's not too complicated to do this.

> quitte_example_data |> 
+     filter(first(scenario) == scenario,
+            first(region) == region, 
+            first(period) == period,
+            variable %in% c('Consumption', 'Population')) |>
+     print() |> 
+     mutate(
+         value = value * ifelse('Consumption' == variable, 1e-3, 1),
+         unit = ifelse('Consumption' == variable, 'trillion US$2005/yr', 
+                       as.character(unit)))
# A tibble: 2 × 7
  model  scenario              region variable    unit               period value
  <fct>  <fct>                 <fct>  <fct>       <fct>               <int> <dbl>
1 REMIND r7552c_1p5C_Def-rem-5 AFR    Consumption billion US$2005/yr   2005  618.
2 REMIND r7552c_1p5C_Def-rem-5 AFR    Population  million              2005  710.
# A tibble: 2 × 7
  model  scenario              region variable    unit                period   value
  <fct>  <fct>                 <fct>  <fct>       <chr>                <int>   <dbl>
1 REMIND r7552c_1p5C_Def-rem-5 AFR    Consumption trillion US$2005/yr   2005   0.618
2 REMIND r7552c_1p5C_Def-rem-5 AFR    Population  million               2005 710.   

Will put this on the list of thing I'll do when all of a sudden there is nothing else that needs doing.

from quitte.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.