{"id":2808,"date":"2021-01-26T16:35:11","date_gmt":"2021-01-26T16:35:11","guid":{"rendered":"http:\/\/jenaexperiment.uni-jena.de\/?page_id=2808"},"modified":"2024-11-20T16:26:17","modified_gmt":"2024-11-20T16:26:17","slug":"r-interface-rbexis","status":"publish","type":"page","link":"https:\/\/the-jena-experiment.de\/index.php\/r-interface-rbexis\/","title":{"rendered":"R interface (rBExIS)"},"content":{"rendered":"\n<h3 class=\"has-vivid-green-cyan-color has-text-color\">For new rBExIS version (updated on 2023-03-13):<\/h3>\n\n\n\n<p>see: <a href=\"https:\/\/github.com\/BEXIS2\/rBExIS#preparation\">https:\/\/github.com\/BEXIS2\/rBExIS#preparation<\/a><\/p>\n\n\n\n<h4><a href=\"https:\/\/github.com\/BEXIS2\/rBExIS#requirements\"><\/a>Requirements<\/h4>\n\n\n\n<ul><li>R (e.g. <a href=\"https:\/\/cran.r-project.org\/bin\/windows\/base\/\">https:\/\/cran.r-project.org\/bin\/windows\/base\/<\/a> for Windows, otherwise start <a href=\"https:\/\/cran.r-project.org\/bin\/\">here<\/a>)<\/li><li>RStudio (<a href=\"https:\/\/www.rstudio.com\/products\/rstudio\/download\/#download\">https:\/\/www.rstudio.com\/products\/rstudio\/download\/#download<\/a>)<\/li><li>Rtools (e.g. <a href=\"https:\/\/cran.r-project.org\/bin\/windows\/Rtools\/\">https:\/\/cran.r-project.org\/bin\/windows\/Rtools\/<\/a> for Windows, , otherwise start <a href=\"https:\/\/cran.r-project.org\/bin\/\">here<\/a>)<\/li><\/ul>\n\n\n\n<h4>Installation<\/h4>\n\n\n\n<p>To uninstall the current version:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">detach(\"package:rBExIS\", unload = TRUE)\nremove.packages(\"rBExIS\")<\/pre>\n\n\n\n<p>To install the new version:<\/p>\n\n\n\n<p> The script depends on the packages <code>httr<\/code>, <code>jsonlite<\/code>, <code>XML<\/code>, <code>rBExIs<\/code>, and <code>tidyverse<\/code>. <code>rBExIs<\/code> installation also depends on <code>devtools<\/code>. If they are not yet installed, they will be installed in the next chunk of code. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sapply(c(\"httr\",\"jsonlite\",\"XML\",\"tidyverse\",\"devtools\"), \n       function(x){\n         if(!require(x,character.only = T)){\n           install.packages(x)\n           require(x,character.only = T)\n         }\n       })<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>if(!require(\"rBExIS\")) install_github(\"BEXIS2\/rBExIS\", subdir = \"rBExIS\")\nrequire(rBExIS)<\/code><\/pre>\n\n\n\n<p>Database webpage and authorization indification:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis.options(\"base_url\" = \"https:\/\/jexis.idiv.de\/\")<\/pre>\n\n\n\n<p class=\"justify\">Within BEXIS2, the functions are either publically  available (i.e. no authentication\/authorization is needed to execute the  function). On the other side, other functions may need authentication  to verify the user of that function. <\/p>\n\n\n\n<p>Here it uses the bearer  token for authentication.<br>To get your token number, to go JEXIS page and log in, under your name, click &#8220;Token&#8221;.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" src=\"\/wp-content\/uploads\/image-93.png\" alt=\"\" class=\"wp-image-2810\" width=\"224\" height=\"96\" srcset=\"\/wp-content\/uploads\/image-93.png 630w, \/wp-content\/uploads\/image-93-300x129.png 300w\" sizes=\"(max-width: 224px) 100vw, 224px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis.options(\"authorization_bearer\" = \"KJkSKJxEoiXwk9ipAvKkNEJ9isGGi64drtQDRf9KKCDRKSE5JYvz5j8Yx5Unvto5\")<\/pre>\n\n\n\n<h4>Functions<\/h4>\n\n\n\n<h5>List of Dataset Ids<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_dataset_ids &lt;- rBExIS::bexis.GetDatasetIds()<\/pre>\n\n\n\n<h5>Data of specific Dataset<\/h5>\n\n\n\n<p>That function uses the parameter <em>id<\/em> to identify the specific dataset you would like to get the data from.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_data &lt;- rBExIS::bexis.GetDatasetById(id)<\/pre>\n\n\n\n<h5>List of Metadata Objects<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_metadata_list &lt;- rBExIS::bexis.GetMetadata()<\/pre>\n\n\n\n<h5>Metadata of specific Dataset<\/h5>\n\n\n\n<p>That function uses the parameter <em>id<\/em> to identify the specific dataset you would like to get the metadata from.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_metadata &lt;- rBExIS::bexis.GetMetadataById(id)<\/pre>\n\n\n\n<h5>List of Data Structures<\/h5>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_structures &lt;- rBExIS::bexis.GetDataStructures()<\/pre>\n\n\n\n<h5>Data Structure of specific Dataset<\/h5>\n\n\n\n<p>That function uses the parameter <em>id<\/em> to identify the specific data structure you would like to get the information\/details from.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_structures &lt;- rBExIS::bexis.GetDataStructureBy()\n<\/pre>\n\n\n\n<h3 class=\"has-vivid-green-cyan-color has-text-color\">For old rBExIS version:<\/h3>\n\n\n\n<p>We need the packages <code>httr<\/code>, <code>jsonlite<\/code>, <code>XML<\/code>, <code>rBExIs<\/code>. <code>rBExIs<\/code> installation also depends on <code>devtools<\/code>. If they are not yet installed, they will be installed in the next chunk of code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sapply(c(\"httr\",\"jsonlite\",\"XML\",\"devtools\"), \n       function(x){\n         if(!require(x,character.only = T)){\n           install.packages(x)\n           require(x,character.only = T)\n         }\n       })\nif(!require(\"rBExIS\")) install_github(\"BEXIS2\/rBExIS\", subdir = \"rBExIS\")\nrequire(rBExIS)<\/code><\/pre>\n\n\n\n<p> bexis.options() # info of the url and token number<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis.options(base_url = \"https:\/\/jexis.idiv.de\/\")<br>token_id&lt;-\u201dXXXXXXXXXX\u201d<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"> bexis.options(token = \u201ctoken_id\") <\/pre>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<p>#get list of all dataset ids<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bexis_dataset_ids &lt;- bexis.get.datasets()<\/pre>\n<\/div><\/div>\n\n\n\n<p>#get data from bexis from dataset with id = xy<br>bexis_data90 &lt;- bexis.get.dataset_by(id = 90)<\/p>\n\n\n\n<p class=\"has-text-color has-luminous-vivid-orange-color\">! The NA value in the database will be read as the maximum double value 1.797693e+307 in R ( .Machine$double.xmax\/10) if you use rBEXIS package.<\/p>\n\n\n\n<p>For example,  here is the code to correct the the biomass &#8220;NA&#8221; data from 2020:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a&lt;-.Machine$double.xmax\/100<br>d2020$biomass[d2020$biomass &gt;a]&lt;-NA<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For new rBExIS version (updated on 2023-03-13): see: https:\/\/github.com\/BEXIS2\/rBExIS#preparation Requirements R (e.g. https:\/\/cran.r-project.org\/bin\/windows\/base\/ for Windows, otherwise start here) RStudio (https:\/\/www.rstudio.com\/products\/rstudio\/download\/#download) Rtools (e.g. https:\/\/cran.r-project.org\/bin\/windows\/Rtools\/ for Windows, , otherwise start here) Installation&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/pages\/2808"}],"collection":[{"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/comments?post=2808"}],"version-history":[{"count":38,"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/pages\/2808\/revisions"}],"predecessor-version":[{"id":5509,"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/pages\/2808\/revisions\/5509"}],"wp:attachment":[{"href":"https:\/\/the-jena-experiment.de\/index.php\/wp-json\/wp\/v2\/media?parent=2808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}