Get a Graphical QL (GQL) token for NABat Database

#library(nabatr)
devtools::load_all(".")

# Enter your NABat username here
username_ = 'Nabat_Username'
token_ = get_nabat_gql_token(username = username_)
token_

# If you are not using R-Studio or are not prompted for a password use this code below
#  to manually add in your password with the password variable:
# token_ = get_nabat_gql_token(username = username_, password = 'your-password')

Get Project dataframe which contains all of your acoustic stationary projects in the NABat Database

# Get your projects lookup table
project_df_ = get_projects(token = token_)
# Display your projects lookup table
project_df_

Get Species dataframe which contains a species lookup table for auto and manual ids

# Get your species lookup table
species_df_ = get_species(token = token_)
# Display your species lookup table
species_df_

Get all Acoustic Stationary Surveys within a single Project set with project_id_

# Fill in project id using the project_df_ lookup table
project_id_ = 275 # Set equal to one of your project ids

# Get survey dataframe 
survey_df_ = get_project_surveys(token      = token_,
                                 project_df = project_df_,
                                 project_id = project_id_)
# Display survey dataframe
survey_df_

Get all Acoustic Stationary Survey wav file data. Format: Acoustic Stationary Bulk Upload Template

colony_bulk_df_ = get_colony_bulk_counts(token = token_,
                                         survey_df = survey_df_,
                                         project_id = project_id_)

colony_bulk_df_

Build Acoustic stationary .docx report

# Edit This file path to your own output directory to store the report (No trailing '/')
out_dir_doc = here::here()
# Build report and return the doc to then save out
doc_ = build_col_doc(out_dir = out_dir_doc,
                    file_name  = paste0('doc_report_','_',Sys.Date(),'.docx'),
                    project_df = project_df_,
                    project_id = project_id_,
                    cover_photo = "/inst/templates/nabat_logo.png",
                    colony_bulk_df = colony_bulk_df_,
                    date = format(Sys.time(), "%B %d, %Y"))

# Save it out to a local directory
print(doc_, target = paste0(out_dir_doc, '/', paste0('colony_count_report_',project_id_,'_',format(Sys.time(), '%Y_%m_%d_%H%M%S'),'.docx')))

Build Acoustic stationary HTML report

# Edit This file path to your own output directory to store the report (No trailing '/')
out_dir_html = '/path/to/output/directory'

# Build Report and save out the report
get_acoustic_stationary_report(token      = token_,
                               output_dir = out_dir_html,
                               file_name  = paste0('report_',project_id_,'_',Sys.Date(),'','.html'),
                               nightly_plots_type = 'sites', # 'grts' | 'sites'
                               output_type = 'html',
                               project_id = project_id_,
                               survey_df = survey_df_,
                               acoustic_bulk_df = acoustic_bulk_df_,
                               nightly_observed_list = nightly_observed_list_,
                               num_plots = 20)


talbertc-usgs/NABatR documentation built on April 22, 2020, 8:23 p.m.