vectorsurvR

VectorSurv

VectorSurv provides public health agencies the tools to manage, visualize and analyze the spread of vector-borne diseases and make informed decisions to protect public health.

The ‘vectorsurvR’ package is intended for users of VectorSurv, a public health vector borne disease surveillance system. The package contains functions tailored to data retrieved from the VectorSurv database. A valid VectorSurv username and password is required for data retrieval. Those without agency access can use sample datasets in place of real data. This documentation covers the functions in ‘vectorsurvR’ and introduces users to methods of R programming. The purpose of this documentation is to introduce and guide users with limited programming experience.

To install package from CRAN (recommended) run:

install.packages("vectorsurvR")

Or install the developing version from our github run:

devtools::install_github("UCD-DART/vectorsurvR")

Then load the package for use.

Data Retrieval

getToken()

Description

getToken() returns a token needed to run getArthroCollections() and getPools(). The function prompts users for their Gateway credentials. If credentials are accepted, the function returns a user token needed to obtain data and a list of agencies the user has access to.

Usage

getToken()

Arguments


token = getToken()

getArthroCollections(…)

Description

getArthroCollections(...) obtains collections data for a range of years. It prompts the user for their Gateway username and password before retrieving the associated data. You can only retrieve data from agencies linked to your Gateway account.

Usage

getArthroCollections(token,start_year, end_year, arthropod, agency_ids = NULL)

Arguments

  • token: access token retrieved from getToken()
  • start_year: Beginning of year range
  • end_year: End of year range
  • arthropod: Type of pools to retrieve: ‘tick’ , ‘mosquito’
  • agency_ids: Default to NULL returns data for all available agencies, specifying a vector of agency ids will return data for specific agencies. This parameter is best used by accounts with access to multiple agencies.
#Example
collections = getArthroCollections(token, 2022,2023, 'mosquito',55)

getPools(…)

Description

getPools() similar to getArthroCollections() obtains pools on a year range (start_year, end_year) after supplying a valid token retrieved from getToken(). getPools() can retrieve data for both mosquito and tick pools.

Usage

getPools(token, start_year, end_year, arthropod, agency_ids = NULL) Arguments

  • token: access token retrieved from getToken()
  • start_year: Beginning of year range
  • end_year: End of year range
  • arthropod: Type of collections to retrieve: ‘tick’ , ‘mosquito’
  • agency_ids: Default to NULL returns data for all available agencies, specifying a vector of agency ids will return data for specific agencies. This parameter is best used by accounts with access to multiple agencies.
#Example
pools = getPools(token, 2022,2023, 'mosquito')

Write Data to file

You can save retrieved data as a .csv file in your current directory using write.csv(). That same data can be retrieved using read.csv(). Writing data to a .csv can make the rendering process more efficient when generating reports in R. We recommend that you write the data pulled from our API into a csv and then load that data when generating reports.

#creates a file named "collections_18_23.csv" in your current directory
write.csv(x = collections, file = "collections_22_23.csv")

#loads collections data
collections = read.csv("collections_22_23.csv")

Sample Data

The ‘vectorsurvR’ package comes with two sample datasets which can be used in place of real collections and pools data. sample_collections and sample_pools will be used for example purposes in this document.

Data Processing

Data can be subset to contain columns of interest. Subsetting can also be used to reorder the columns in a data frame.Do not subset collections or pools data before inputting them into VectorSurv calculator functions to avoid losing essential columns. It is recommended to subset after calculations are complete and before inputting into a table generator. Remember, subsetting, filtering, grouping and summarising will not change the value of the data unless it is reassigned to the same variable name. We recommend creating a new variable for processed data.

Subsetting

#Subset using column names or index number


colnames(sample_collections) #displays column names and associated index
#>  [1] "collection_id"        "collection_date"      "surv_year"           
#>  [4] "species_display_name" "sex_type"             "trap_acronym"        
#>  [7] "trap_problem_bit"     "num_trap"             "trap_nights"         
#> [10] "num_count"            "site_code"



#Subseting by name
head(sample_collections[c("collection_date", "species_display_name", "num_count")])
#>   collection_date species_display_name num_count
#> 1      2016-06-11          Cs incidens        23
#> 2      2016-08-06           Cx pipiens        11
#> 3      2016-10-11          Cx tarsalis         3
#> 4      2016-08-12          Cx tarsalis        23
#> 5      2016-06-04      Cx stigmatosoma         1
#> 6      2016-05-29           Cx pipiens       106

#by index
head(sample_collections[c(2, 4, 10)])
#>   collection_date species_display_name num_count
#> 1      2016-06-11          Cs incidens        23
#> 2      2016-08-06           Cx pipiens        11
#> 3      2016-10-11          Cx tarsalis         3
#> 4      2016-08-12          Cx tarsalis        23
#> 5      2016-06-04      Cx stigmatosoma         1
#> 6      2016-05-29           Cx pipiens       106

#to save a subset
collections_subset = sample_collections[c(2, 4, 10)]

Filtering and subsetting in ‘dplyr’

‘dplyr’ is a powerful package for filtering and sub-setting data. It follows logic similar to SQL queries.

For more information on data manipulation using ‘dplyr’ Click Here

‘dplyr’ utilizes the pipe operator %>% to send data into functions. The head() function returns the first few rows of data, specifying head(1) tells the software to return only the first row for viewing purposes. Remove head() to see all the data or reassign the data to a new variable.

#NOTE: library was loaded above
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

#Subsetting columns with 'select()'
sample_collections %>%
  dplyr::select(collection_date, species_display_name, num_count) %>% head()
#>   collection_date species_display_name num_count
#> 1      2016-06-11          Cs incidens        23
#> 2      2016-08-06           Cx pipiens        11
#> 3      2016-10-11          Cx tarsalis         3
#> 4      2016-08-12          Cx tarsalis        23
#> 5      2016-06-04      Cx stigmatosoma         1
#> 6      2016-05-29           Cx pipiens       106

Below are more examples for filtering data.


#filtering with dplyr 'filter'
collections_pip = sample_collections %>%
  filter(species_display_name == "Cx pipiens")

#filtering multiple arguments using '%in%'
collections_pip_tar = sample_collections %>%
  filter(species_display_name %in% c("Cx pipiens", "Cx tarsalis"))

Grouping and Summarising

In addition to filtering and sub-setting, data can be group by variables and summarised.

#groups by species and collection date and sums the number counted

sample_collections %>%
  group_by(collection_date, species_display_name) %>%
  summarise(sum_count = sum(num_count, na.rm = T)) %>%
  head()
#> `summarise()` has grouped output by 'collection_date'. You can override using
#> the `.groups` argument.
#> # A tibble: 6 × 3
#> # Groups:   collection_date [5]
#>   collection_date species_display_name sum_count
#>   <chr>           <chr>                    <int>
#> 1 2016-01-02      Cs inornata                  1
#> 2 2016-01-07      Cx pipiens                   2
#> 3 2016-01-22      Cs inornata                  8
#> 4 2016-01-22      Cx pipiens                   7
#> 5 2016-01-28      Cx tarsalis                  3
#> 6 2016-02-25      Cx pipiens                   1


#groups by species and collection date and takes the average the number counted

sample_collections %>%
  group_by(collection_date, species_display_name) %>%
  summarise(avg_count = mean(num_count, na.rm = T)) %>%
  head()
#> `summarise()` has grouped output by 'collection_date'. You can override using
#> the `.groups` argument.
#> # A tibble: 6 × 3
#> # Groups:   collection_date [5]
#>   collection_date species_display_name avg_count
#>   <chr>           <chr>                    <dbl>
#> 1 2016-01-02      Cs inornata                1  
#> 2 2016-01-07      Cx pipiens                 2  
#> 3 2016-01-22      Cs inornata                8  
#> 4 2016-01-22      Cx pipiens                 7  
#> 5 2016-01-28      Cx tarsalis                1.5
#> 6 2016-02-25      Cx pipiens                 1

Pivoting

Data can be manipulated into long and wide (spreadsheet) forms using pivot_wider() and pivot_longer() from the ‘tidyr’ package. By default data from the API is in long form. Here we pivot on species and sex condition names using num_count as values. The end result is data with num_count values in the columns named species_sex. For more on pivoting see ??pivot_longer() and ??pivot_wider().

library(tidyr)

collections_wide = pivot_wider(
  sample_collections,
  names_from = c("species_display_name","sex_type"),
  values_from = "num_count"
)

Calculations

Abundance

getAbundance(…)

Description

getAbundance() uses any amount of mosquito collections data to calculate the abundance for the specified parameters. The function calculates using the methods of the Gateway Abundance calculator.

Usage

getAbundance(collections,interval, species_list = NULL, trap_list = NULL, species_separate = FALSE)

Arguments

  • collections: Mosquito collections data retrieved from getArthroCollections(...)
  • interval: Calculation interval for abundance, accepts “collection_date”,“Biweek”,“Week”, and “Month.
  • species_list: Species filter for calculating abundance. Species_display_name is the accepted notation. To see a list of species present in your data run unique(collections$species_display_name). If species is unspecified, the default NULL will return data for all species in data.
  • trap_list: Trap filter for calculating abundance. Trap_acronym is the is the accepted notation. Run unique(collections$trap_acronym) to see trap types present in your data. If trap_list is unspecified, the default NULL will return data for all trap types.
  • species_separate: Should the species in species_list have abundance calculated separately? Setting to FALSE calculates the combined abundance. The same result can be performed by calculating on one species at the time.
getAbundance(
  sample_collections,
  interval = "Biweek",
  species_list = c("Cx tarsalis", "Cx pipiens"),
  trap_list = "CO2",
  species_separate = FALSE
)
#>    surv_year Biweek Count Trap_Events Abundance
#> 1       2020     11   298           8     37.25
#> 2       2020     12    96          17      5.65
#> 3       2020     13    95          11      8.64
#> 4       2020     14   977          16     61.06
#> 5       2020     15   366          14     26.14
#> 6       2020     16   541          12     45.08
#> 7       2020     17   106           9     11.78
#> 8       2020     18    17           7      2.43
#> 9       2020     19   314          15     20.93
#> 10      2020     20    44          10      4.40
#> 11      2020     21   364           9     40.44
#> 12      2020     22     2           4      0.50
#> 13      2020     23    10           6      1.67
#> 14      2019      4     6           1      6.00
#> 15      2019      9   166           9     18.44
#> 16      2019     10     9           4      2.25
#> 17      2019     11    43           9      4.78
#> 18      2019     12    60          10      6.00
#> 19      2019     13    75          10      7.50
#> 20      2019     14    61          11      5.55
#> 21      2019     15   216           9     24.00
#> 22      2019     16    41          13      3.15
#> 23      2019     17    87           6     14.50
#> 24      2019     18    13           8      1.62
#> 25      2019     19    37           6      6.17
#> 26      2019     20     6           5      1.20
#> 27      2019     21    10           4      2.50
#> 28      2018      9    19           2      9.50
#> 29      2018     10    22           6      3.67
#> 30      2018     11    70           6     11.67
#> 31      2018     12    63           9      7.00
#> 32      2018     13   198          12     16.50
#> 33      2018     14    88           8     11.00
#> 34      2018     15    39           5      7.80
#> 35      2018     16    56          10      5.60
#> 36      2018     17   289          24     12.04
#> 37      2018     18  1424          21     67.81
#> 38      2018     19   980          21     46.67
#> 39      2018     20   104          12      8.67
#> 40      2018     21     4           5      0.80
#> 41      2017      9    74           4     18.50
#> 42      2017     10     4          10      0.40
#> 43      2017     11    62          20      3.10
#> 44      2017     12   137          13     10.54
#> 45      2017     13   189          20      9.45
#> 46      2017     14   299          15     19.93
#> 47      2017     15  2231          16    139.44
#> 48      2017     16   437          17     25.71
#> 49      2017     17   159          20      7.95
#> 50      2017     18   338          16     21.12
#> 51      2017     19   135          11     12.27
#> 52      2017     20   148          17      8.71
#> 53      2017     21     1           5      0.20
#> 54      2016      8     1           3      0.33
#> 55      2016      9    27           6      4.50
#> 56      2016     10     7          11      0.64
#> 57      2016     11    67          12      5.58
#> 58      2016     12   238          19     12.53
#> 59      2016     13  1003          21     47.76
#> 60      2016     14   616          24     25.67
#> 61      2016     15   324          16     20.25
#> 62      2016     16  2237          13    172.08
#> 63      2016     17   931          18     51.72
#> 64      2016     18    51           5     10.20
#> 65      2016     19    96          11      8.73
#> 66      2016     20    19           6      3.17
#> 67      2016     21     3           3      1.00

Abundance Anomaly (comparison to 5 year average)

getAbundanceAnomaly()

Description

getAbundanceAnomaly(...) requires at least five years prior to the target_year of mosquito collections data to calculate for the specified parameters. The function uses the methods of the Gateway Abundance Anomaly calculator, and will not work if there is fewer than five years of data present.

Usage

getAbundanceAnomaly(collections,interval,target_year, species_list = NULL, trap_list = NULL, species_separate = FALSE)

Arguments

  • collections: Collections data retrieved from getArthroCollections(...)
  • interval: Calculation interval for abundance, accepts “collection_date”,“Biweek”,“Week”, and “Month.
  • target_year: Year to calculate analysis on. Collections data must have a year range of at least (target_year - 5, target_year).
  • species_list: Species filter for calculating abundance. Species_display_name is the accepted notation. To see a list of species present in your data run unique(collections$species_display_name). If species is unspecified, the default NULL will return data for all species in data.
  • trap_list: Trap filter for calculating abundance. Trap_acronym is the is the accepted notation. Run unique(collections$trap_acronym) to see trap types present in your data. If trap_list is unspecified, the default NULL will return data for all trap types.
  • species_separate: Should the species in species_list have abundance calculated separately? Setting to FALSE calculates the combined abundance. The same result can be performed by calculating on one species at the time.

getAbundanceAnomaly(sample_collections,
                    interval = "Biweek",
                    target_year = 2020,
                    species_list = c("Cx tarsalis", "Cx pipiens"),
                    trap_list = "CO2",
                    species_separate = FALSE) 
#>    Biweek surv_year Count Trap_Events Abundance Five_Year_Avg
#> 1      11      2020   298           8     37.25        6.2825
#> 2      12      2020    96          17      5.65        9.0175
#> 3      13      2020    95          11      8.64       20.3025
#> 4      14      2020   977          16     61.06       15.5375
#> 5      15      2020   366          14     26.14       47.8725
#> 6      16      2020   541          12     45.08       51.6350
#> 7      17      2020   106           9     11.78       21.5525
#> 8      18      2020    17           7      2.43       25.1875
#> 9      19      2020   314          15     20.93       18.4600
#> 10     20      2020    44          10      4.40        5.4375
#> 11     21      2020   364           9     40.44        1.1250
#>       Years_In_Average   Delta
#> 1  2016,2017,2018,2019  492.92
#> 2  2016,2017,2018,2019  -37.34
#> 3  2016,2017,2018,2019  -57.44
#> 4  2016,2017,2018,2019  292.98
#> 5  2016,2017,2018,2019  -45.40
#> 6  2016,2017,2018,2019  -12.69
#> 7  2016,2017,2018,2019  -45.34
#> 8  2016,2017,2018,2019  -90.35
#> 9  2016,2017,2018,2019   13.38
#> 10 2016,2017,2018,2019  -19.08
#> 11 2016,2017,2018,2019 3494.67

Infection Rate

getInfectionRate()

Description

getInfectionRate(...) estimates the arbovirus infection rate based on testing pools of mosquitoes.

Usage

getInfectionRate(pools,interval, target_year, target_disease,pt_estimate, scale = 1000, species_list = c(NULL), trap_list = c(NULL))

Arguments

  • pools: Pools data retrieved from getPools(...)
  • interval: Calculation interval for abundance, accepts: “Biweek”,“Week”, and “Month.
  • target_year: Year to calculate infection rate for. This year must be present in the data.
  • target_disease: The disease to calculate infection rate for–i.e. “WNV”. Disease acronyms are the accepted input. To see a list of disease acronyms, run unique(pools$target_acronym).
  • pt_estimate: The estimation type for infection rate. Options include: “mle”,“bc-”mle”, “mir”
  • scale: Constant to multiply result
  • species_list: Species filter for calculating abundance. Species_display_name is the accepted notation. To see a list of species present in your data run unique(pools$species_display_name). If species is unspecified, the default NULL will return data for all species in data.
  • trap_list: Trap filter for calculating abundance. Trap_acronym is the is the accepted notation. Run unique(pools$trap_acronym) to see trap types present in your data. If trap_list is unspecified, the default NULL will return data for all trap types.
IR = getInfectionRate(sample_pools, 
                      interval = "Week",
                      target_disease = "WNV",
                      pt_estimate = "mle", 
                      scale = 1000,
                      species_list = c("Cx pipiens"),
                      trap_list = c("CO2","GRVD") )
IR
#>     surv_year Week Disease Point_Estimate Lower_CI  Upper_CI    Species
#> 1        2016   18     WNV       0.000000        0   0.00000 Cx pipiens
#> 2        2016   19     WNV       0.000000        0   0.00000 Cx pipiens
#> 3        2016   20     WNV       0.000000        0   0.00000 Cx pipiens
#> 4        2016   21     WNV       0.000000        0   0.00000 Cx pipiens
#> 5        2016   22     WNV       0.000000        0   0.00000 Cx pipiens
#> 6        2016   23     WNV       0.000000        0   0.00000 Cx pipiens
#> 7        2016   24     WNV       0.000000        0   0.00000 Cx pipiens
#> 8        2016   25     WNV       0.000000        0   0.00000 Cx pipiens
#> 9        2016   26     WNV       0.000000        0   0.00000 Cx pipiens
#> 10       2016   27     WNV       0.000000        0   0.00000 Cx pipiens
#> 11       2016   28     WNV       0.000000        0   0.00000 Cx pipiens
#> 12       2016   29     WNV       0.000000        0   0.00000 Cx pipiens
#> 13       2016   30     WNV       0.000000        0   0.00000 Cx pipiens
#> 14       2016   31     WNV       0.000000        0   0.00000 Cx pipiens
#> 15       2016   32     WNV       0.000000        0   0.00000 Cx pipiens
#> 16       2016   33     WNV       0.000000        0   0.00000 Cx pipiens
#> 17       2016   34     WNV       9.919259        0  29.96644 Cx pipiens
#> 18       2016   36     WNV       0.000000        0   0.00000 Cx pipiens
#> 19       2016   37     WNV       0.000000        0   0.00000 Cx pipiens
#> 20       2016   38     WNV       0.000000        0   0.00000 Cx pipiens
#> 21       2016   39     WNV       0.000000        0   0.00000 Cx pipiens
#> 22       2016   40     WNV       0.000000        0   0.00000 Cx pipiens
#> 23       2017   20     WNV       0.000000        0   0.00000 Cx pipiens
#> 24       2017   21     WNV       0.000000        0   0.00000 Cx pipiens
#> 25       2017   22     WNV       0.000000        0   0.00000 Cx pipiens
#> 26       2017   23     WNV       0.000000        0   0.00000 Cx pipiens
#> 27       2017   24     WNV       0.000000        0   0.00000 Cx pipiens
#> 28       2017   25     WNV       0.000000        0   0.00000 Cx pipiens
#> 29       2017   26     WNV       0.000000        0   0.00000 Cx pipiens
#> 30       2017   27     WNV       0.000000        0   0.00000 Cx pipiens
#> 31       2017   28     WNV       0.000000        0   0.00000 Cx pipiens
#> 32       2017   29     WNV       0.000000        0   0.00000 Cx pipiens
#> 33       2017   30     WNV       0.000000        0   0.00000 Cx pipiens
#> 34       2017   31     WNV       0.000000        0   0.00000 Cx pipiens
#> 35       2017   32     WNV       0.000000        0   0.00000 Cx pipiens
#> 36       2017   33     WNV       0.000000        0   0.00000 Cx pipiens
#> 37       2017   34     WNV      18.519273        0  57.95015 Cx pipiens
#> 38       2017   35     WNV       0.000000        0   0.00000 Cx pipiens
#> 39       2017   36     WNV       0.000000        0   0.00000 Cx pipiens
#> 40       2017   37     WNV      41.716029        0 136.36790 Cx pipiens
#> 41       2017   38     WNV      31.814287        0  90.22213 Cx pipiens
#> 42       2017   39     WNV       0.000000        0   0.00000 Cx pipiens
#> 43       2017   40     WNV       0.000000        0   0.00000 Cx pipiens
#> 44       2017   41     WNV       0.000000        0   0.00000 Cx pipiens
#> 45       2017   42     WNV       0.000000        0   0.00000 Cx pipiens
#> 46       2018   20     WNV       0.000000        0   0.00000 Cx pipiens
#> 47       2018   21     WNV       0.000000        0   0.00000 Cx pipiens
#> 48       2018   22     WNV       0.000000        0   0.00000 Cx pipiens
#> 49       2018   23     WNV       0.000000        0   0.00000 Cx pipiens
#> 50       2018   24     WNV       0.000000        0   0.00000 Cx pipiens
#> 51       2018   25     WNV       0.000000        0   0.00000 Cx pipiens
#> 52       2018   26     WNV       0.000000        0   0.00000 Cx pipiens
#> 53       2018   27     WNV       0.000000        0   0.00000 Cx pipiens
#> 54       2018   28     WNV       0.000000        0   0.00000 Cx pipiens
#> 55       2018   29     WNV       0.000000        0   0.00000 Cx pipiens
#> 56       2018   30     WNV       0.000000        0   0.00000 Cx pipiens
#> 57       2018   31     WNV       0.000000        0   0.00000 Cx pipiens
#> 58       2018   32     WNV       0.000000        0   0.00000 Cx pipiens
#> 59       2018   34     WNV       0.000000        0   0.00000 Cx pipiens
#> 60       2018   35     WNV       0.000000        0   0.00000 Cx pipiens
#> 61       2018   36     WNV       0.000000        0   0.00000 Cx pipiens
#> 62       2018   37     WNV       0.000000        0   0.00000 Cx pipiens
#> 63       2018   38     WNV       0.000000        0   0.00000 Cx pipiens
#> 64       2018   39     WNV       0.000000        0   0.00000 Cx pipiens
#> 65       2018   41     WNV       0.000000        0   0.00000 Cx pipiens
#> 66       2018   42     WNV       0.000000        0   0.00000 Cx pipiens
#> 67       2019   18     WNV       0.000000        0   0.00000 Cx pipiens
#> 68       2019   19     WNV       0.000000        0   0.00000 Cx pipiens
#> 69       2019   20     WNV       0.000000        0   0.00000 Cx pipiens
#> 70       2019   21     WNV       0.000000        0   0.00000 Cx pipiens
#> 71       2019   22     WNV       0.000000        0   0.00000 Cx pipiens
#> 72       2019   23     WNV       0.000000        0   0.00000 Cx pipiens
#> 73       2019   24     WNV       0.000000        0   0.00000 Cx pipiens
#> 74       2019   25     WNV       0.000000        0   0.00000 Cx pipiens
#> 75       2019   26     WNV       0.000000        0   0.00000 Cx pipiens
#> 76       2019   27     WNV       0.000000        0   0.00000 Cx pipiens
#> 77       2019   28     WNV       0.000000        0   0.00000 Cx pipiens
#> 78       2019   29     WNV       0.000000        0   0.00000 Cx pipiens
#> 79       2019   30     WNV       0.000000        0   0.00000 Cx pipiens
#> 80       2019   31     WNV       0.000000        0   0.00000 Cx pipiens
#> 81       2019   33     WNV       0.000000        0   0.00000 Cx pipiens
#> 82       2019   34     WNV       0.000000        0   0.00000 Cx pipiens
#> 83       2019   35     WNV       0.000000        0   0.00000 Cx pipiens
#> 84       2019   36     WNV       0.000000        0   0.00000 Cx pipiens
#> 85       2019   37     WNV       0.000000        0   0.00000 Cx pipiens
#> 86       2019   38     WNV       0.000000        0   0.00000 Cx pipiens
#> 87       2019   39     WNV       0.000000        0   0.00000 Cx pipiens
#> 88       2019   40     WNV       0.000000        0   0.00000 Cx pipiens
#> 89       2019   41     WNV       0.000000        0   0.00000 Cx pipiens
#> 90       2019   42     WNV       0.000000        0   0.00000 Cx pipiens
#> 91       2020   20     WNV       0.000000        0   0.00000 Cx pipiens
#> 92       2020   22     WNV       0.000000        0   0.00000 Cx pipiens
#> 93       2020   23     WNV       0.000000        0   0.00000 Cx pipiens
#> 94       2020   24     WNV       0.000000        0   0.00000 Cx pipiens
#> 95       2020   25     WNV       0.000000        0   0.00000 Cx pipiens
#> 96       2020   26     WNV      25.334014        0  72.94264 Cx pipiens
#> 97       2020   27     WNV       0.000000        0   0.00000 Cx pipiens
#> 98       2020   28     WNV       9.459394        0  28.42011 Cx pipiens
#> 99       2020   30     WNV      22.952926        0  68.12985 Cx pipiens
#> 100      2020   31     WNV      18.329540        0  55.38780 Cx pipiens
#> 101      2020   32     WNV       0.000000        0   0.00000 Cx pipiens
#> 102      2020   33     WNV       0.000000        0   0.00000 Cx pipiens
#> 103      2020   34     WNV       0.000000        0   0.00000 Cx pipiens
#> 104      2020   35     WNV       0.000000        0   0.00000 Cx pipiens
#> 105      2020   36     WNV       0.000000        0   0.00000 Cx pipiens
#> 106      2020   37     WNV       0.000000        0   0.00000 Cx pipiens
#> 107      2020   38     WNV       0.000000        0   0.00000 Cx pipiens
#> 108      2020   39     WNV       0.000000        0   0.00000 Cx pipiens
#> 109      2020   40     WNV       0.000000        0   0.00000 Cx pipiens
#> 110      2020   42     WNV       0.000000        0   0.00000 Cx pipiens
#> 111      2020   47     WNV       0.000000        0   0.00000 Cx pipiens
#>     Trap_Type
#> 1        GRVD
#> 2    CO2,GRVD
#> 3    CO2,GRVD
#> 4         CO2
#> 5        GRVD
#> 6    CO2,GRVD
#> 7    CO2,GRVD
#> 8    CO2,GRVD
#> 9    CO2,GRVD
#> 10        CO2
#> 11        CO2
#> 12   CO2,GRVD
#> 13   CO2,GRVD
#> 14   CO2,GRVD
#> 15       GRVD
#> 16   CO2,GRVD
#> 17   CO2,GRVD
#> 18   CO2,GRVD
#> 19   CO2,GRVD
#> 20   CO2,GRVD
#> 21        CO2
#> 22        CO2
#> 23   CO2,GRVD
#> 24   CO2,GRVD
#> 25   CO2,GRVD
#> 26       GRVD
#> 27   CO2,GRVD
#> 28        CO2
#> 29   CO2,GRVD
#> 30        CO2
#> 31        CO2
#> 32       GRVD
#> 33   CO2,GRVD
#> 34   CO2,GRVD
#> 35        CO2
#> 36   CO2,GRVD
#> 37   CO2,GRVD
#> 38   CO2,GRVD
#> 39       GRVD
#> 40   CO2,GRVD
#> 41   CO2,GRVD
#> 42   CO2,GRVD
#> 43        CO2
#> 44       GRVD
#> 45        CO2
#> 46       GRVD
#> 47   CO2,GRVD
#> 48        CO2
#> 49       GRVD
#> 50   CO2,GRVD
#> 51   CO2,GRVD
#> 52   CO2,GRVD
#> 53       GRVD
#> 54   CO2,GRVD
#> 55       GRVD
#> 56   CO2,GRVD
#> 57        CO2
#> 58       GRVD
#> 59   CO2,GRVD
#> 60        CO2
#> 61   CO2,GRVD
#> 62   CO2,GRVD
#> 63   CO2,GRVD
#> 64   CO2,GRVD
#> 65   CO2,GRVD
#> 66       GRVD
#> 67       GRVD
#> 68        CO2
#> 69       GRVD
#> 70   CO2,GRVD
#> 71   CO2,GRVD
#> 72   CO2,GRVD
#> 73   CO2,GRVD
#> 74        CO2
#> 75   CO2,GRVD
#> 76        CO2
#> 77        CO2
#> 78   CO2,GRVD
#> 79   CO2,GRVD
#> 80   CO2,GRVD
#> 81   CO2,GRVD
#> 82   CO2,GRVD
#> 83   CO2,GRVD
#> 84   CO2,GRVD
#> 85   CO2,GRVD
#> 86   CO2,GRVD
#> 87        CO2
#> 88   CO2,GRVD
#> 89   CO2,GRVD
#> 90   CO2,GRVD
#> 91        CO2
#> 92        CO2
#> 93   CO2,GRVD
#> 94   CO2,GRVD
#> 95   CO2,GRVD
#> 96   CO2,GRVD
#> 97        CO2
#> 98   CO2,GRVD
#> 99   CO2,GRVD
#> 100  CO2,GRVD
#> 101  CO2,GRVD
#> 102  CO2,GRVD
#> 103       CO2
#> 104  CO2,GRVD
#> 105  CO2,GRVD
#> 106      GRVD
#> 107  CO2,GRVD
#> 108       CO2
#> 109  CO2,GRVD
#> 110  CO2,GRVD
#> 111      GRVD

Vector Index

getVectorIndex()

Description

getVectorIndex(...) The vector index is the relative abundance of infected mosquitoes and is a way to quickly estimate the risk of arbovirus transmission in an area. Vector index is the product of the abundance and infection rate for a given time interval: VectorIndex = InfectionRate * Abundance

Usage

getVectorIndex(collections, pools, interval, , target_disease, pt_estimate,species_list=NULL, trap_list = NULL)

Arguments - collections: collections data retrieved from getArthroCollections(...) - pools: Pools data retrieved from getPools(...)

Note: Years from pools and collections data must overlap

  • interval: Calculation interval for abundance, accepts “collection_date”,“Biweek”,“Week”, and “Month.

  • target_disease: The disease to calculate infection rate. Disease acronyms are the accepted input. To see a list of disease acronyms, run unique(pools$target_acronym).

  • pt_estimate: The estimation type for infection rate. Options include: “mle”,“bc-”mle”, “mir”.

  • species_list: Species filter for calculating abundance. Species_display_name is the accepted notation. To see a list of species present in your data run unique(pools$species_display_name). If species is unspecified, the default NULL will return data for all species in data.

  • trap_list: Trap filter for calculating abundance. Trap_acronym is the is the accepted notation. Run unique(pools$trap_acronym) to see trap types present in your data. If trap_list is unspecified, the default NULL will return data for all trap types.



getVectorIndex(sample_collections, sample_pools, interval = "Biweek",
                           
                           target_disease = "WNV", pt_estimate = "bc-mle",
                           species_list=c("Cx tarsalis"), 
                           
                           trap_list =  c("CO2"))
#>    Biweek surv_year Count Trap_Events Abundance Disease Point_Estimate Lower_CI
#> 1      10      2016     7          11      0.64     WNV       0.000000        0
#> 2      10      2017     3          10      0.30     WNV       0.000000        0
#> 3      10      2018     8           6      1.33     WNV       0.000000        0
#> 4      11      2016     4          12      0.33     WNV       0.000000        0
#> 5      11      2017    44          20      2.20     WNV       0.000000        0
#> 6      11      2018    23           6      3.83     WNV       0.000000        0
#> 7      11      2019    23           9      2.56     WNV       0.000000        0
#> 8      11      2020   186           8     23.25     WNV       0.000000        0
#> 9      12      2016    11          19      0.58     WNV       0.000000        0
#> 10     12      2017   125          13      9.62     WNV       0.000000        0
#> 11     12      2018     8           9      0.89     WNV       0.000000        0
#> 12     12      2020    78          17      4.59     WNV       0.000000        0
#> 13     13      2016    43          21      2.05     WNV       0.000000        0
#> 14     13      2017   144          20      7.20     WNV       0.000000        0
#> 15     13      2018   187          12     15.58     WNV       0.000000        0
#> 16     13      2019     4          10      0.40     WNV       0.000000        0
#> 17     13      2020    41          11      3.73     WNV       0.000000        0
#> 18     14      2016   503          24     20.96     WNV       0.000000        0
#> 19     14      2017   279          15     18.60     WNV       0.000000        0
#> 20     14      2018    74           8      9.25     WNV       0.000000        0
#> 21     14      2019    38          11      3.45     WNV      10.007176        0
#> 22     14      2020   891          16     55.69     WNV       0.000000        0
#> 23     15      2016   311          16     19.44     WNV       0.000000        0
#> 24     15      2017  2212          16    138.25     WNV       0.000000        0
#> 25     15      2018    27           5      5.40     WNV       0.000000        0
#> 26     15      2019   211           9     23.44     WNV       0.000000        0
#> 27     15      2020    62          14      4.43     WNV       0.000000        0
#> 28     16      2016  2209          13    169.92     WNV       3.181438        0
#> 29     16      2017   414          17     24.35     WNV       0.000000        0
#> 30     16      2018    47          10      4.70     WNV       0.000000        0
#> 31     16      2019    33          13      2.54     WNV       7.872627        0
#> 32     16      2020   514          12     42.83     WNV       0.000000        0
#> 33     17      2016   817          18     45.39     WNV       8.495922        0
#> 34     17      2017   154          20      7.70     WNV       0.000000        0
#> 35     17      2018    60          24      2.50     WNV       6.614069        0
#> 36     17      2019    44           6      7.33     WNV       0.000000        0
#> 37     17      2020   106           9     11.78     WNV       4.815421        0
#> 38     18      2016    51           5     10.20     WNV       0.000000        0
#> 39     18      2017   330          16     20.62     WNV       0.000000        0
#> 40     18      2018  1365          21     65.00     WNV       5.660557        0
#> 41     18      2019    13           8      1.62     WNV       3.240647        0
#> 42     18      2020    17           7      2.43     WNV       0.000000        0
#> 43     19      2016    95          11      8.64     WNV       0.000000        0
#> 44     19      2017     8          11      0.73     WNV       0.000000        0
#> 45     19      2018   781          21     37.19     WNV       6.546427        0
#> 46     19      2019    37           6      6.17     WNV       0.000000        0
#> 47     19      2020   202          15     13.47     WNV       5.652328        0
#> 48     20      2016    12           6      2.00     WNV       0.000000        0
#> 49     20      2017    80          17      4.71     WNV       0.000000        0
#> 50     20      2018    65          12      5.42     WNV       0.000000        0
#> 51     20      2019     3           5      0.60     WNV       0.000000        0
#> 52     20      2020     6          10      0.60     WNV       0.000000        0
#> 53     21      2016     3           3      1.00     WNV       0.000000        0
#> 54     21      2017     1           5      0.20     WNV       0.000000        0
#> 55     21      2018     4           5      0.80     WNV       0.000000        0
#> 56     21      2020   346           9     38.44     WNV       0.000000        0
#> 57      9      2016    27           6      4.50     WNV       0.000000        0
#> 58      9      2017    19           4      4.75     WNV       0.000000        0
#> 59      9      2019   126           9     14.00     WNV       0.000000        0
#>     Upper_CI     Species Trap_Type VectorIndex
#> 1   0.000000 Cx tarsalis       CO2    0.000000
#> 2   0.000000 Cx tarsalis       CO2    0.000000
#> 3   0.000000 Cx tarsalis       CO2    0.000000
#> 4   0.000000 Cx tarsalis       CO2    0.000000
#> 5   0.000000 Cx tarsalis       CO2    0.000000
#> 6   0.000000 Cx tarsalis       CO2    0.000000
#> 7   0.000000 Cx tarsalis       CO2    0.000000
#> 8   0.000000 Cx tarsalis       CO2    0.000000
#> 9   0.000000 Cx tarsalis       CO2    0.000000
#> 10  0.000000 Cx tarsalis       CO2    0.000000
#> 11  0.000000 Cx tarsalis       CO2    0.000000
#> 12  0.000000 Cx tarsalis       CO2    0.000000
#> 13  0.000000 Cx tarsalis       CO2    0.000000
#> 14  0.000000 Cx tarsalis       CO2    0.000000
#> 15  0.000000 Cx tarsalis       CO2    0.000000
#> 16  0.000000 Cx tarsalis       CO2    0.000000
#> 17  0.000000 Cx tarsalis       CO2    0.000000
#> 18  0.000000 Cx tarsalis       CO2    0.000000
#> 19  0.000000 Cx tarsalis       CO2    0.000000
#> 20  0.000000 Cx tarsalis       CO2    0.000000
#> 21 33.733395 Cx tarsalis       CO2   34.524758
#> 22  0.000000 Cx tarsalis       CO2    0.000000
#> 23  0.000000 Cx tarsalis       CO2    0.000000
#> 24  0.000000 Cx tarsalis       CO2    0.000000
#> 25  0.000000 Cx tarsalis       CO2    0.000000
#> 26  0.000000 Cx tarsalis       CO2    0.000000
#> 27  0.000000 Cx tarsalis       CO2    0.000000
#> 28  9.651421 Cx tarsalis       CO2  540.590010
#> 29  0.000000 Cx tarsalis       CO2    0.000000
#> 30  0.000000 Cx tarsalis       CO2    0.000000
#> 31 24.263369 Cx tarsalis       CO2   19.996472
#> 32  0.000000 Cx tarsalis       CO2    0.000000
#> 33 26.573728 Cx tarsalis       CO2  385.629914
#> 34  0.000000 Cx tarsalis       CO2    0.000000
#> 35 20.733675 Cx tarsalis       CO2   16.535173
#> 36  0.000000 Cx tarsalis       CO2    0.000000
#> 37 14.596417 Cx tarsalis       CO2   56.725660
#> 38  0.000000 Cx tarsalis       CO2    0.000000
#> 39  0.000000 Cx tarsalis       CO2    0.000000
#> 40 17.446834 Cx tarsalis       CO2  367.936205
#> 41  9.783041 Cx tarsalis       CO2    5.249848
#> 42  0.000000 Cx tarsalis       CO2    0.000000
#> 43  0.000000 Cx tarsalis       CO2    0.000000
#> 44  0.000000 Cx tarsalis       CO2    0.000000
#> 45 20.859118 Cx tarsalis       CO2  243.461630
#> 46  0.000000 Cx tarsalis       CO2    0.000000
#> 47 18.446891 Cx tarsalis       CO2   76.136859
#> 48  0.000000 Cx tarsalis       CO2    0.000000
#> 49  0.000000 Cx tarsalis       CO2    0.000000
#> 50  0.000000 Cx tarsalis       CO2    0.000000
#> 51  0.000000 Cx tarsalis       CO2    0.000000
#> 52  0.000000 Cx tarsalis       CO2    0.000000
#> 53  0.000000 Cx tarsalis       CO2    0.000000
#> 54  0.000000 Cx tarsalis       CO2    0.000000
#> 55  0.000000 Cx tarsalis       CO2    0.000000
#> 56  0.000000 Cx tarsalis       CO2    0.000000
#> 57  0.000000 Cx tarsalis       CO2    0.000000
#> 58  0.000000 Cx tarsalis       CO2    0.000000
#> 59  0.000000 Cx tarsalis       CO2    0.000000

Tables

getPoolsComparisionTable()

Description

getPoolsComparisionTable() produces a frequency table for positive and negative pools counts by year and species. The more years present in the data, the larger the table.

Usage

getPoolsComparisionTable(pools,target_disease, species_separate=F)

Arguments

  • pools: Pools data retrieved from getPools(...)
  • target_disease: The disease to calculate infection rate for–i.e. “WNV”. Disease acronyms are the accepted input. To see a list of disease acronyms, run unique(pools$target_acronym).
  • species_separate: Should the pools comparison be split by species of each pool. Default is FALSE.
getPoolsComparisionTable(
  sample_pools,
  interval = "Week",
  target_disease = "WNV",
  species_separate = T
)
#> # A tibble: 220 × 7
#> # Groups:   Year, species_display_name, Week [220]
#>     Year  Week species_display_name Negative Confirmed Total `Percent Positive`
#>    <int> <dbl> <chr>                   <int>     <int> <int>              <dbl>
#>  1  2016    18 Cx pipiens                  1         0     1                  0
#>  2  2016    19 Cx pipiens                  6         0     6                  0
#>  3  2016    20 Cx pipiens                  3         0     3                  0
#>  4  2016    21 Cx pipiens                  1         0     1                  0
#>  5  2016    22 Cx pipiens                  2         0     2                  0
#>  6  2016    23 Cx pipiens                  8         0     8                  0
#>  7  2016    24 Cx pipiens                  4         0     4                  0
#>  8  2016    25 Cx pipiens                  7         0     7                  0
#>  9  2016    26 Cx pipiens                  4         0     4                  0
#> 10  2016    27 Cx pipiens                  2         0     2                  0
#> # ℹ 210 more rows

Styling Dataframes with ‘kable’

Professional looking tables can be produced using the ‘kable’ and ‘kableExtra’ packages.



library(kableExtra)
#> 
#> Attaching package: 'kableExtra'
#> The following object is masked from 'package:dplyr':
#> 
#>     group_rows

AbAnOutput = getAbundance(
  sample_collections,
  interval = "Biweek",
  
  species_list = c("Cx tarsalis", "Cx pipiens"),
  trap_list = "CO2",
  species_separate = FALSE
)
head(AbAnOutput)
#>   surv_year Biweek Count Trap_Events Abundance
#> 1      2020     11   298           8     37.25
#> 2      2020     12    96          17      5.65
#> 3      2020     13    95          11      8.64
#> 4      2020     14   977          16     61.06
#> 5      2020     15   366          14     26.14
#> 6      2020     16   541          12     45.08

#kable table where column names, font_size, style and much more can be customized

AbAnOutput %>%
  kbl(col.names = c("Disease Year", "Biweek", "Count", "Trap Events", "Abundance")) %>%
  kable_styling(
    bootstrap_options = "striped",
    font_size = 14,
    latex_options = "scale_down"
  ) %>%
  footnote(general = "Table X: Combined biweekly Abundance Calculation for Cx. tarsalis, pipiens in CO2 traps", general_title = "")
Disease Year Biweek Count Trap Events Abundance
2020 11 298 8 37.25
2020 12 96 17 5.65
2020 13 95 11 8.64
2020 14 977 16 61.06
2020 15 366 14 26.14
2020 16 541 12 45.08
2020 17 106 9 11.78
2020 18 17 7 2.43
2020 19 314 15 20.93
2020 20 44 10 4.40
2020 21 364 9 40.44
2020 22 2 4 0.50
2020 23 10 6 1.67
2019 4 6 1 6.00
2019 9 166 9 18.44
2019 10 9 4 2.25
2019 11 43 9 4.78
2019 12 60 10 6.00
2019 13 75 10 7.50
2019 14 61 11 5.55
2019 15 216 9 24.00
2019 16 41 13 3.15
2019 17 87 6 14.50
2019 18 13 8 1.62
2019 19 37 6 6.17
2019 20 6 5 1.20
2019 21 10 4 2.50
2018 9 19 2 9.50
2018 10 22 6 3.67
2018 11 70 6 11.67
2018 12 63 9 7.00
2018 13 198 12 16.50
2018 14 88 8 11.00
2018 15 39 5 7.80
2018 16 56 10 5.60
2018 17 289 24 12.04
2018 18 1424 21 67.81
2018 19 980 21 46.67
2018 20 104 12 8.67
2018 21 4 5 0.80
2017 9 74 4 18.50
2017 10 4 10 0.40
2017 11 62 20 3.10
2017 12 137 13 10.54
2017 13 189 20 9.45
2017 14 299 15 19.93
2017 15 2231 16 139.44
2017 16 437 17 25.71
2017 17 159 20 7.95
2017 18 338 16 21.12
2017 19 135 11 12.27
2017 20 148 17 8.71
2017 21 1 5 0.20
2016 8 1 3 0.33
2016 9 27 6 4.50
2016 10 7 11 0.64
2016 11 67 12 5.58
2016 12 238 19 12.53
2016 13 1003 21 47.76
2016 14 616 24 25.67
2016 15 324 16 20.25
2016 16 2237 13 172.08
2016 17 931 18 51.72
2016 18 51 5 10.20
2016 19 96 11 8.73
2016 20 19 6 3.17
2016 21 3 3 1.00
Table X: Combined biweekly Abundance Calculation for Cx. tarsalis, pipiens in CO2 traps

Data using ‘datatables’

Interactive html only tables can be produced using the ‘DT’ package. ‘DT’ tables allow for sorting and filtering with in a webpage. These are ideal for viewing data but are not compatible with pdf or word formats.

library(DT)

AbAnOutput %>%
  datatable(colnames =  c("Disease Year", "Biweek", "Count", "Trap Events", "Abundance"))

Charts and Graphs

‘ggplot2’ is a easy to use plotting library in R. ‘ggplot2’ syntax consists of creating a ggplot object with a dataframe and adding subsequent arguments to that object. Aesthetics (aes()) in ggplot represents the data mapping aspect of the plot. A simple example using collections is shown below.

library(ggplot2)
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
#creates a month column and translates numerics
sample_collections$month = as.factor(month(sample_collections$collection_date))


collections_sums = sample_collections %>%
  filter(
    species_display_name %in% c(
      "Cx tarsalis",
      "Cx pipiens",
      "An freeborni",
      "Cs incidens",
      "Ae melanimon",
      "Cs inornata",
      "Cx stigmatosoma",
      "Cx erythrothorax",
      "Ae vexans",
      "I pacificus"
    )
  ) %>%
  group_by(month, species_display_name) %>%
  summarise(sum_count = sum(num_count, na.rm = T)) %>% arrange(desc(sum_count), .by_group = T)
#> `summarise()` has grouped output by 'month'. You can override using the
#> `.groups` argument.



#ggplot with dots a values for each species of interest

ggplot(data = collections_sums,
       aes(x = month, y = sum_count, color = species_display_name)) +
  geom_point()


#bar chart
ggplot(data = collections_sums,
       aes(x = month, y = sum_count, fill = species_display_name)) +
  geom_bar(stat = "identity")



#adding labels
ggplot(data = collections_sums,
       aes(x = month, y = sum_count, fill = species_display_name)) +
  geom_bar(stat = "identity") +
  labs(title = "Mosquito Counts by Month and Species",
       x = "Month",
       y = "Sum of Mosquitoes",
       fill = "Species")

When plotting with libraries in R, it is easiest when the data is prepared in long form. Most calculator outputs from our functions are in wide form. The following wrapper functions help process and plot this data.

processAbunAnom()

Description

processAbunAnom() processes the output returned from getAbundanceAnomaly() into a long form suitable for plotting in ‘ggplot’

Usage

processAbunAnom(AbAnomOutput)

Arguments

  • AbAnomOutput: Output from returned getAbundanceAnomaly()



AbAnOut = getAbundanceAnomaly(
  sample_collections,
  interval = "Biweek",
  target_year = 2020,
  species_list = c("Cx tarsalis", "Cx pipiens"),
  species_separate = TRUE
)



AbAnOut_L = processAbunAnom(AbAnOut)
#> Warning in colnames(AbAnomOutput)[grep("Abundance", colnames(AbAnomOutput), :
#> number of items to replace is not a multiple of replacement length

We can take the output of processAbunAnom() and create a plot comparing the target year abundance to the five year average.



AbAnOut_L %>%  filter(Abundance_Type %in% c("2020_Abundance",
                                            "Five_Year_Avg")) %>%
  ggplot(aes(x = Biweek,
             y = Abundance_Calculation,
             color = Abundance_Type)) +
  geom_point() +
  geom_line() +
  facet_wrap( ~ species_display_name) +
  labs(title = "2020 Abundance Anomaly", y = "")

We can also create a plot which displays the percent change from the five year average.

AbAnOut_L %>%
  filter(Abundance_Type == "Delta") %>%
  mutate(Change = ifelse(Abundance_Calculation > 0, "Increase", "Decrease")) %>%
  ggplot(aes(x = Biweek,
             y = Abundance_Calculation,
             fill = Change)) +
  geom_bar(stat = "identity") +
  facet_wrap( ~ species_display_name) +
  labs(x = "Biweek",
       y = "Percent Change",
       title = "Relative Abundance 2023, % Change from 5-year average",
       fill = "Relative Change")

plotInfectionRate()

Description

plotInfectionRate() plots the output returned from getInfectionRate() with confidence intervals using ‘ggplot2’.

Usage

plotInfectionRate(InfRtOutput, year)

Arguments

  • InfRtOutput: Output from returned getInfectionRate()
  • year: Desired year of plot (year must be in data)
IR = getInfectionRate(
  sample_pools,
  interval = "Week",
  target_disease = "WNV",
  pt_estimate = "mle",
  species_list = c("Cx pipiens"),
  trap_list = c("CO2", "GRVD")
)

plotInfectionRate(InfRtOutput = IR, year = 2020)

Additional Table Examples

We can highlight rows and columns, add headers, and customize footnotes. For more information please Click Here


table(sample_collections$trap_acronym, sample_collections$surv_year) %>%
  kbl(align = "c") %>%
  kable_paper(
    full_width = F,
    html_font = "arial",
    lightable_options = "striped",
  ) %>%
  add_header_above(c("Trap Type", "Years" = 5)) %>%
  footnote(general = "Table X: Traps deployed by year", general_title = "") %>%
  row_spec(c(3, 9, 10), background = "yellow") %>%
  column_spec(c(4), background = "orange")
Trap Type
Years
2016 2017 2018 2019 2020
BACKPACK 0 0 1 1 0
BGSENT 19 0 113 152 142
BTLJC 1 0 0 0 0
CO2 183 187 148 108 140
FLANNEL 0 0 0 0 1
GRVD 202 220 151 162 147
LCKR 35 73 85 75 70
NJLT 60 20 0 0 0
OTHER 0 0 2 0 0
OVI 0 0 0 2 0
Table X: Traps deployed by year