|
|
Line 1: |
Line 1: |
− | [[Category:Opasnet]]
| + | Pages that relate to the [[R]] package [[OpasnetUtils]] (previously called OpasnetBaseUtils). |
− | [[Category:R tools]]
| |
− | | |
− | ==OpasnetUtils features==
| |
− | [[Modelling in Opasnet]] is done using R and the OpasnetUtils package provides most of the actual tools. Most of the package revolves around the [[Ovariable]]-class.
| |
− | | |
− | Defining and analyzing endpoints of a model can be as easy as Fetching a relevant variable, evaluating it (using EvalOutput) and using some of the available functions (i.e. summary() for ovariables).
| |
− | | |
− | ...
| |
− | | |
− | ==List/Glossary of package contents==
| |
− | Find more about each function or method using ?<topic> in the R console or search the [[#Manual]]. Topics are in approximate order of prevalency.
| |
− | | |
− | ===Ovariable functionalities===
| |
− | *EvalOutput - is the method used to evaluate ovariables.
| |
− | *ComputeDependencies - is automatically run when evaluating ovariables to fetch and evaluate any dependencies they have.
| |
− | *CheckMarginals - is automatically run when evaluating ovariables to check the marginal status of output indices.
| |
− | *CheckInput - is automatically run when evaluating ovariables to incorporate input definitions if available.
| |
− | *CheckCollapse - is automatically run when evaluating ovariables. Uses CollapseMarginal if orders are present.
| |
− | *CheckDecisions - is automatically run when evaluating ovariables. Adds scenarios to output if their definitions are present.
| |
− | *CollapseMarginal - is used to streamline large models by removing indices through summation etc.
| |
− | | |
− | ===Assessment tools===
| |
− | *DecisionTableParser - parses scenarios used in decision analysis from data.frames.
| |
− | *CollapseTableParser - parses collapse orders from data.frames.
| |
− | *Optimize - finds optimal combination of index values.
| |
− | *Minimize - finds optimal combination of index values so that the resulting value is minimal.
| |
− | | |
− | ===Custom methods for Opasnet and ovariables===
| |
− | *oprint - prints a data.frame or the output of an ovariable as a html formatted table so it looks nice on the web page.
| |
− | *oapply - uses tapply on ovariable output. Instead of defining INDEX you can define cols as the column names you want to remove.
| |
− | *orbind - uses rbind on the output slots two ovariables. Differing columns are allowed (missing ones are added automatically).
| |
− | *combine - is similar to orbind, but more efficient and combines source columns.
| |
− | *merge - merges ovariable outputs.
| |
− | *summary - provides common statistics about the data using tapply. Defaults to describing the distribution about each ovariable index.
| |
− | *plot - plots ovariable output. Defaults to comparison of data and formula results.
| |
− | *Ops - methods for mathematical operations between ovariables (i.e. X * Y).
| |
− | *Math - methods for single variable mathematical operations (i.e. exp(X)).
| |
− | | |
− | ===External (serverside) data and objects===
| |
− | *opbase.data - downloads data from the Opasnet database.
| |
− | *opbase.upload - uploads data to the Opasnet database.
| |
− | *opbase.locations - downloads the index information of a particular dataset.
| |
− | *opbase.obj.exists - checks whether object (as identified by page identifier) exists in the database.
| |
− | *opbase.series - downloads list of datasets for a particular object.
| |
− | *opasnet.data - downloads data from any file uploaded to Opasnet as text.
| |
− | *opasnet.csv - downloads data from any .csv file uploaded to Opasnet.
| |
− | *objects.get - downloads saved R objects matching a key.
| |
− | *objects.latest - downloads latest saved R objects matching a code block in Opasnet.
| |
− | *objects.put - uploads R objects. Returns key.
| |
− | *objects.store - uploads public R objects in Opasnet code block.
| |
− | *objects.encode - encrypts R objects.
| |
− | *objects.decode - decrypts R objects.
| |
− | | |
− | ===General tools===
| |
− | *Ovariable - constructs ovariables. More feature than new("ovariable", ...).
| |
− | *Fetch - downloads saved R objects in batch fashion.
| |
− | *tidy - makes common adjustments to data.frames used for ovariable data slots.
| |
− | *interpret - forms a probability distributions based on regular expressions [[OpasnetUtils/Interpret]].
| |
− | *result - accesses the result column of the output slot of an ovariable. Result(X) <- y -shortcut is possible.
| |
− | *ddata_apply - updates data slot of an ovariable based on a link in the ddata slot. Does not overwrite unless force_ddata = TRUE.
| |
− | *convert.units - is a unit conversion engine.
| |
− | *fillna - looks for empty column values (NA) in specified data.frame columns and replaces them with all other values in the same column.
| |
− | *dropall - cleans factors of unused levels.
| |
− | | |
− | ===Health impact assessment===
| |
− | *GIS.Exposure - does spatial exposure mapping.
| |
− | *GIS.Concentration.matrix - does spatial concentration mapping based on point emission.
| |
− | | |
− | ==Installation==
| |
− | | |
− | === Installation of RStudio and rgdal in Ubuntu ===
| |
− | | |
− | OpasnetUtils is available from the CRAN repository on any platform capable of running R. Use the drop down menu in the RGui or the R command install.packages("OpasnetUtils") to download the most recent official release.
| |
− | | |
− | In Ubuntu machines, you will probably have problems with the rgdal package. Therefore, this is a detailed description how that was successfully done in Ubuntu 16.04 (32-bit version because the computers were old):
| |
− | | |
− | 1) Install R by adding this instruction to the file /etc/apt/sources.list [https://cran.r-project.org/bin/linux/ubuntu/] (this particular code uses a Danish mirror to download packages. Note that the file is write-protected and you may need command ''sudo gedit'' to open the file):
| |
− | deb <nowiki>https://mirrors.dotsrc.org/cran/bin/linux/ubuntu</nowiki> xenial/
| |
− | | |
− | 2) Then, in the terminal, run these commands:
| |
− | sudo apt-get update
| |
− | sudo apt-get install r-base
| |
− | | |
− | 3) The rgdal package does not install properly from R. Therefore, you should run these commands from the terminal first [https://philmikejones.wordpress.com/2014/07/14/installing-rgdal-in-r-on-linux/]:
| |
− | sudo apt-get update && sudo apt-get install libgdal-dev libproj-dev
| |
− | | |
− | 4) Then, install RStudio by clicking the right version from [https://www.rstudio.com/products/rstudio/download/]. Follow instructions to install.
| |
− | | |
− | 5) Search your computer to find R and RStudio. Drag their icons to the left taskbar to make it easy to launch them.
| |
− | | |
− | 6) Open RStudio and from ''Tools / Install packages...'' install at least packages OpasnetUtils, ggplot2, rgdal, and reshape2 ''with'' dependencies.
| |
− | | |
− | ===SVN repository===
| |
− | | |
− | If you would like to acquire the most recent version, you are welcome to download and compile our source code which is available at https://www.opasnet.org/svn/opasnet_utils/trunk/. For most recent function definitions see [https://www.opasnet.org/svn/opasnet_utils/trunk/R/ the R sub folder]. Compilation on Windows machines requires R tools (See the CRAN homepage for more information).
| |
− | | |
− | ==Manual==
| |
− | | |
− | [[File:OpasnetUtils-manual.pdf]]
| |