Here we use as an example the sweetpotatobase.org database since it has currently one of the most complete implementations. Also, data are public and no login credentials are needed. It is part of the white list of the internal databases, too. So no further knowledge of configuration details are needed.
The package comes with a list of known databases (white list). Both the white list and the handle can be printed in summary form to the console. The $ sign can be used to access individual slots and overwrite values. This can also be used as a template to configure a handle to another brapi compliant database.
library(brapi) library(magrittr) white_list <- ba_db() # print names of databases from whitelist white_list sp_base <- ba_db()$sweetpotatobase # print summary of sp_base object sp_base
In many cases when exploring a new database it will be useful to get any feedback from the server. The package provides a switch that allows to turn on or off such log information.
ba_show_info(TRUE)
The brapi community and standard allows currently a large degree of freedom on implementation of individual parts of the standard (or calls). One call lists the functionality supported by the server.
ba_calls(sp_base) ba_show_info(FALSE)
As you notice, the table is presented as a tibble. This has the advantage that it fits on the screen always even though there are big tables. But sometimes it may be useful to just print out the whole table. How to do that is the topic of the next section.
All functions always have two parameters: the first is always the database handle or connection details ('con'), the last is always the R class of the returned object. Most parameters should be of class 'character'. Exceptions are: the con parameter is always a list; the parameters 'page' and 'pageSize' if applicable are integers. For details see individual functions.
This is by default a tibble. However, there are several others supported. An alternative is the 'data.frame'. In addition and mainly for debugging purposes you can set the value to 'json' which will return the full response json object; or you can set it to 'list' which will return a list equivalent.
So, let's just print out the whole data.frame.
ba_calls(con = sp_base, rclass = "data.frame")
The brapi models trial data in a three layer hierarchy: a) breeding program which has b) trials that c) may consist of one or more studies at one or more locations. A study at one location is also often referred to as a fieldbook.
ba_programs(sp_base, rclass = "data.frame")
ba_studies_search(sp_base, programDbId = "140")
# Currently not working!!! #dt = ba_studies_table(sp_base, # studyDbId = "151")
#library(DT) #datatable( # dt, # options=list(pageLength = 5, scrollX = TRUE) # )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.