Why code for broader impact?


Science is meant to be shared! c4bi and its accompanying publication provide a framework, workflow, code, and examples to faciliate knowledge exchange between ecologists and their stakeholders. It’s often time consuming and tedious to create hundreds of plots and unique research summaries when data is collected across dozens of stakeholder sites. The template code here will help you more readily prepare your dataset(s) to create individualized reports in .html documents that can be distributed to your stakeholders via print or digital media.

You may be interested in this code if you are:

  • an extension specialist looking to create individual pest reports across farm locations
  • a wildlife biologist surveying multiple sites and wanting to share your findings across your stakeholder sites
  • an environmental scientist seeking to send customized pollution assessments
  • OR a person with a ton of data from many places and want unique summary documents for each place

Instructions for use

  1. Clone (download) the code repository to a local folder on your computer. The repository can be found here. NOTE: This repository is large due to many photo files (~100MB). If you want to avoid cloning the entire repository and still want to employ this framework, choose the template files in the report_code folder and copy them to your local computer. Alternatively, you can delete files from the repository on your local device as needed after you learn the gist of workflow. The instructions below apply if you are working with the entire repository.
  2. Choose the repository folder for either the template or one of the case studies. These folders are located within the ‘report_code’ folder.
  3. Open the .R Script file for the template or case study.
  4. Edit the .R Script by setting the working directory to the c4bi repository.
  5. Install any packages not previously installed on your device. Below are the required packages.
install.packages("dplyr")
install.packages("ggplot2")
install.packages("rmarkdown")
install.packages("reshape2")
install.packages("tidyr")
install.packages("kableExtra")
install.packages("here")
install.packages("ggsci")
install.packages("RColorBrewer")
install.packages("plyr")
install.packages("knitr")
  1. Run the .R Script.
  2. Check to make sure that .html documents are generated in the report_ouput folder in your working directory. If not, then work through the steps again.
  3. Edit the .R Script as needed for your project.
  4. Open the .Rmd file within the same folder for the .R script you are working with.
  5. Edit the .Rmd as needed for your project.
  6. Print out new reports for your project to the folder with the folder for the respective script.
  7. Once you get a handle on this approach, feel free to change paths with the render() function to whatever location works best for you. Note: the .Rmd and .R file should be located in the same path as the location for your report outputs.

Template Code

We provide a template .R and .Rmd pair of files in the report_code/template folder with 3 sample reports. This template code uses a simulated, heuristic dataset of bird and tree counts across three parks in three towns. Birds were sampled in each park for 10 days. We plot these data in individualized plots across the three towns to following the Coding for broader impact framework, which encourages highlighting each site in the context of the entire study for helpful comparisons. The data for the template code is available by cloning/downloading the repository.

Case Studies

  • A quick reference of the .R, .Rmd, and .html files described below can be found in the Template + Case Studies tab.
  • A documentation for all .rda files in this package can be found in the Data tab.

Case Study 1: Curaçao homeowners

This case study summarizes biodiversity surveys for reptiles, amphibians, birds, and arthropods at homes and undeveloped natural sites across the Caribbean island of Curaçao. We contextualize each of 31 focal sites by comparing diversity on the focal site to diversity across sites in a variety of land use categories. In the /report_code/homeowner_reports folder, you will find an .R script, an .Rmd script, and 3 sample reports as .html documents, which can be opened in any Internet browser. We used Chrome to print these .html files to pdfs, which we then assembled with other documents and then created bound paper reports that we distributed to home owners. The data files used with the .R and .Rmd are located as .rda files in the data folder and in raw .csv form in the data_raw folder. By cloning the repository, you will already be able to load the .rda files in the respective .R and .Rmd files.

Case Study 2: Southeastern Pennsylvania organic farmers

This case study summarizes biodiversity surveys for beneficial predatory arthropods on organic farms across an urbanization gradient in southeastern Pennsylvania. We contextualize each of 15 focal farms across categories of urbanization intensity. In this case study, we provided two reports to each farmer. The first report provided summary diversity metrics of what was found on each farm in comparison to other farms. The second report was in respones to feedback from farmers about the first report. In the /report_code/farmer_reports_iter1 folder, you will find an .R script, an .Rmd script, and 6 sample reports as .html documents for this first round of reports. This second report focuses on land management strategies that promote beneficial arthropod diversity. In the /report_code/farmer_reports_iter2 folder, you will find an .R script, an .Rmd script, and 3 sample reports as .html documents for the second round of reports.

Case Study 3: Southeastern Pennsylvania property managers (ticks)

This case study summarizes tick-borne diseases and host diversity in forest patches around southeastern Pennsylvania. We contextualize multiple sites for each of six stakeholders and compare their data across county means. In the /report_code/tick_reports folder, you will find an .R script, an .Rmd script, and 6 sample reports as .html documents. We converted these .html documents to .pdf documents rapidly through a loop using pagedown::chrome_print() before distribution to property managers.


Feedback

This package is distributed as is. Please see the feedback information below if you would like to add a feature or if you found a bug. We welcome feedback.

Please read and follow these simple rules before submitting a feature, bug or pull request. (these rules are blatantly copied from here)

  • If you have a new idea for how the scripts should be restructured, please open an issue (tagged ‘enhancement’) to discuss it first before making a pull request.

  • If you you’ve found a bug, open an issue (tagged ‘bug’) that contains a minimal, complete, and verifiable example. We’ll try and get back to you quickly. If you are able to solve the bug on your own, please post the correction.

  • If you have a feature request, open an issue (tagged ‘enhancement’) to discuss it. We’re much more likely to be able to do it if you can be clear and concise about what you want, and if you have already written some code that you would like to merge. If you are requesting a complicated analysis technique that is not available, then consider bringing one of the authors of the individual code repositories on as a collaborator.