library(nabatr) # 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') # Note: if you leave run token_ = get_nabat_gql_token(), # it will prompt you for a username and then a password
# Refresh token token_ = get_refresh_token(token_) # Get your projects lookup table project_df_ = get_projects(token = token_) # Display your projects lookup table project_df_
# Refresh token token_ = get_refresh_token(token_) # Get your species lookup table species_df_ = get_species(token = token_) # Display your species lookup table species_df_
# Refresh token
token_ = get_refresh_token(token_)
# Fill in project id using the project_df_ lookup table
project_id_ = 284 # Set equal to one of your project ids
# Get survey dataframe
survey_df_ = get_acoustic_project_summary(token = token_,
project_id = project_id_,
project_df = project_df_)
proj_dates = unique(survey_df_$year)
# Display survey dataframe
survey_df_
# Select Year for project (defaults to 1st available year)
year_ = proj_dates[1]
# Refresh token
token_ = get_refresh_token(token_)
# Get stationary acoustic bulk upload format dataframe
acoustic_bulk_df_ = get_acoustic_bulk_wavs(token = token_,
survey_df = survey_df_,
project_id = project_id_,
year = year_)
# Display stationary acoustic bulk upload format dataframe
acoustic_bulk_df_
# Get Acoustic stationary acoustic bulk dataframe nightly_observed_list_ = get_observed_nights(acoustic_bulk_df_) auto_nights_df_ = nightly_observed_list_$auto_nightly_df manual_nights_df_ = nightly_observed_list_$manual_nightly_df # Display the two dataframes manual_nights_df_ auto_nights_df_
# Individual species totals for either Manual or Automatic manual_species_totals_l_ = get_species_counts_long(manual_nights_df_, filter=TRUE) auto_species_totals_l_ = get_species_counts_long(auto_nights_df_, filter=TRUE) # Both Manual and Automatic species totals all_species_totals_l_l_ = get_all_species_counts_long(auto_nights_df_, manual_nights_df_, fil = TRUE)
# Extract totals from project at GRTS cell id and GRTS site name # MANUAL manual_species_totals_w_ = get_species_counts_wide(manual_nights_df_) # --- totals at sites manual_species_sites_df_w_ = manual_species_totals_w_$species_site_id_df # --- totals at GRTS cell id manual_species_grts_df_w_ = manual_species_totals_w_$species_grts_df # AUTOMATIC auto_species_totals_w_ = get_species_counts_wide(auto_nights_df_) # --- totals at sites auto_species_sites_df_w_ = auto_species_totals_w_$species_site_id_df # --- totals at GRTS cell id auto_species_grts_df_w_ = auto_species_totals_w_$species_grts_df
grts_map = get_grts_leaflet_map(all_grts = unique(subset(survey_df_, survey_df_$year == year_)$grts_cell_id),
grts_with_data = unique(auto_nights_df_$GRTS),
project_df = project_df_,
project_id = project_id_)
# Display the grts map
grts_map
# Refresh token
token_ = get_refresh_token(token_)
# Edit This file path to your own output directory to store the report (No trailing '/')
out_dir_doc = '/path/to/output/directory'
# Build report and return the doc to then save out
doc_ = build_ac_doc(out_dir = out_dir_doc,
file_name = paste0('doc_report_',project_id_,'_',Sys.Date(),'.docx'),
project_df = project_df_,
project_id = project_id_,
auto_nights_df = auto_nights_df_,
manual_nights_df = manual_nights_df_,
map = grts_map,
manual_species_grts_df_w = manual_species_grts_df_w_,
auto_species_grts_df_w = auto_species_grts_df_w_,
auto_species_totals_l = auto_species_totals_l_,
manual_species_totals_l = manual_species_totals_l_,
date = format(Sys.time(), "%B %d, %Y"),
acoustic_bulk_df = acoustic_bulk_df_,
range_maps = FALSE)
# Note: Setting range_maps = FALSE will significantly decrease processing time
# Save it out to a local directory
print(doc_, target = paste0(out_dir_doc, '/', paste0(year_, '_doc_report_',project_id_,'_',format(Sys.time(), '%Y_%m_%d_%H%M%S'),'.docx')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.