Skip to content

Instantly share code, notes, and snippets.

@bcow
Created July 3, 2018 15:30
Show Gist options
  • Save bcow/b007c56374ad60f6843dd2faf7049daa to your computer and use it in GitHub Desktop.
Save bcow/b007c56374ad60f6843dd2faf7049daa to your computer and use it in GitHub Desktop.
Getting started with BETY

The BETY database

This is the official documentation for BETY: https://pecan.gitbook.io/betydb-documentation/betydb-tables

There is also a good bit of information about BETY in the PEcAn documentation as well https://pecanproject.github.io/pecan-documentation/develop

There are many instances of the database that are synced periodically. The master version is https://www.betydb.org/

The version you will be using is the copy that is hosted at BU on the psql-pecan server. It can be found at http://psql-pecan.bu.edu/bety You will never need to ssh directly to this server. You can access it from test-pecan.

You will need to make an account in BETY at http://psql-pecan.bu.edu/bety

This is also where you can interact with the online interface for the database. Honestly, it isn't very good and I recommend using R commands whenever possible.

Using BETY in R

The function betyConnect() takes the login information from web/config.php and uses it to make a connection with the database.

You will find in the shiny code bety <- betyConnect()

This works when the app is run with the app directory as the working directory (which is automatically set when the app is executed). However, when you are testing in Rstudio, the working directory is automatically set to the pecan directory and so the betyConnect() function will fail because it can't find config.php. In this case, I would manually set your working directory to the shiny app directory.

Commands for accessing BETY

We are trying to use tiddyverse commands as much as possible. While we still have some old code written before dbplyr was commonly used, we are slowly migrating the code to use the new functions. http://r4ds.had.co.nz/introduction.html

All the functions for accessing the database are in the PEcAn.DB module. If you write new functions that you think would be useful, feel free to add them to this module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment