Skip to content

Commit

Permalink
Use syntax highlighting in doc/api-r.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Jan 24, 2021
1 parent 3d43f92 commit 80ccf7c
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions doc/api-r.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ R (``rixmp`` package)
*********************

An R interface to the `ixmp` is provided by the ``rixmp`` package.
``rixmp`` uses the `reticulate <https://rstudio.github.io/reticulate/>`_ R-to-Python adapter to provide access to all features of the :mod:`ixmp` *Python* package::
``rixmp`` uses the `reticulate <https://rstudio.github.io/reticulate/>`_ R-to-Python adapter to provide access to all features of the :mod:`ixmp` *Python* package

# Load the rixmp package
library(rixmp)
ixmp <- import('ixmp')
.. code-block:: R
# An 'ixmp' object is added to the global namespace.
# It can be used in the same way as the Python ixmp package.
mp <- ixmp$Platform(dbtype = 'HSQLDB')
scen <- ixmp$Scenario(mp, 'model name', 'scenario name', version = 'new')
# Load the rixmp package
library(rixmp)
ixmp <- import('ixmp')
# etc.
# An 'ixmp' object is added to the global namespace.
# It can be used in the same way as the Python ixmp package.
mp <- ixmp$Platform(dbtype = 'HSQLDB')
scen <- ixmp$Scenario(mp, 'model name', 'scenario name', version = 'new')
# etc.
One additional method, :meth:`adapt_to_ret` is provided.
Access its documentation with::
Access its documentation with

.. code-block:: R
?rixmp::adapt_to_ret
?rixmp::adapt_to_ret
This function is useful when adding :class:`data.frames` objects to a Scenario:

This function is useful when adding :class:`data.frames` objects to a Scenario::
.. code-block:: R
scen$init_set("i")
i.set = c("seattle", "san-diego")
scen$add_set("i", i.set)
# load dataframes
scen$init_par("a", c("i"))
a.df = data.frame(i = i.set, value = c(350, 600) , unit = 'cases')
scen$add_par("a", adapt_to_ret(a.df))
scen$init_set("i")
i.set = c("seattle", "san-diego")
scen$add_set("i", i.set)
# load dataframes
scen$init_par("a", c("i"))
a.df = data.frame(i = i.set, value = c(350, 600) , unit = 'cases')
scen$add_par("a", adapt_to_ret(a.df))

0 comments on commit 80ccf7c

Please sign in to comment.