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

#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

#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] "agency_code"          "collection_id"        "collection_date"     
#>  [4] "surv_year"            "species_display_name" "sex_type"            
#>  [7] "trap_acronym"         "trap_problem_bit"     "num_trap"            
#> [10] "trap_nights"          "num_count"            "site_code"

#Subseting by name
head(sample_collections[c("collection_date", "species_display_name", "num_count")])
#> # A tibble: 6 × 3
#>   collection_date species_display_name num_count
#>   <date>          <chr>                    <int>
#> 1 2016-07-26      Ae nigromaculis             21
#> 2 2016-08-07      Cx tarsalis                  1
#> 3 2016-07-23      Cx pipiens                  83
#> 4 2016-05-21      Ae vexans                   12
#> 5 2016-03-25      Cx pipiens                   1
#> 6 2016-08-13      Ae vexans                    1

#by index
head(sample_collections[c(2, 4, 10)])
#> # A tibble: 6 × 3
#> # Groups:   surv_year [1]
#>   collection_id surv_year trap_nights
#>           <int>     <dbl>       <int>
#> 1       1878571      2016           1
#> 2       1886007      2016           7
#> 3       1874021      2016           1
#> 4       1585849      2016           1
#> 5       1544658      2016           7
#> 6       1891660      2016           7

#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()
#> Adding missing grouping variables: `surv_year`
#> # A tibble: 6 × 4
#> # Groups:   surv_year [1]
#>   surv_year collection_date species_display_name num_count
#>       <dbl> <date>          <chr>                    <int>
#> 1      2016 2016-07-26      Ae nigromaculis             21
#> 2      2016 2016-08-07      Cx tarsalis                  1
#> 3      2016 2016-07-23      Cx pipiens                  83
#> 4      2016 2016-05-21      Ae vexans                   12
#> 5      2016 2016-03-25      Cx pipiens                   1
#> 6      2016 2016-08-13      Ae vexans                    1

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 summarized.

#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 [4]
#>   collection_date species_display_name sum_count
#>   <date>          <chr>                    <int>
#> 1 2016-01-03      Cs inornata                  1
#> 2 2016-01-14      Cs incidens                  2
#> 3 2016-01-14      Cx pipiens                   1
#> 4 2016-01-14      Cx tarsalis                  1
#> 5 2016-01-22      Cx tarsalis                  1
#> 6 2016-02-05      An freeborni                 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 [4]
#>   collection_date species_display_name avg_count
#>   <date>          <chr>                    <dbl>
#> 1 2016-01-03      Cs inornata                  1
#> 2 2016-01-14      Cs incidens                  2
#> 3 2016-01-14      Cx pipiens                   1
#> 4 2016-01-14      Cx tarsalis                  1
#> 5 2016-01-22      Cx tarsalis                  1
#> 6 2016-02-05      An freeborni                 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"
)
#> Warning: Values from `num_count` are not uniquely identified; output will contain
#> list-cols.
#> • Use `values_fn = list` to suppress this warning.
#> • Use `values_fn = {summary_fun}` to summarise duplicates.
#> • Use the following dplyr code to identify duplicates.
#>   {data} |>
#>   dplyr::summarise(n = dplyr::n(), .by = c(agency_code, collection_id,
#>   collection_date, surv_year, trap_acronym, trap_problem_bit, num_trap,
#>   trap_nights, site_code, species_display_name, sex_type)) |>
#>   dplyr::filter(n > 1L)

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 = NULL, trap = NULL, separate_by = NULL)

Arguments

getAbundance(
  sample_collections,
  interval = "Biweek",
  species = c("Cx tarsalis", "Cx pipiens"),
  trap = "CO2",
  separate_by = NULL
)
#>                Agency Year Biweek                 Species Count TrapEvents Trap
#> 1  Agency_1, Agency_2 2020     10              Cx pipiens    12          4  CO2
#> 2            Agency_2 2020     11             Cx tarsalis   100          6  CO2
#> 3  Agency_1, Agency_2 2020     12 Cx pipiens, Cx tarsalis    81          5  CO2
#> 4  Agency_1, Agency_2 2020     13 Cx pipiens, Cx tarsalis  4431         14  CO2
#> 5  Agency_1, Agency_2 2020     14 Cx pipiens, Cx tarsalis  1359         19  CO2
#> 6  Agency_1, Agency_2 2020     15 Cx pipiens, Cx tarsalis   543         19  CO2
#> 7  Agency_1, Agency_2 2020     16 Cx pipiens, Cx tarsalis   818         19  CO2
#> 8  Agency_1, Agency_2 2020     17 Cx pipiens, Cx tarsalis  1244          6  CO2
#> 9  Agency_1, Agency_2 2020     18 Cx pipiens, Cx tarsalis   394         16  CO2
#> 10 Agency_1, Agency_2 2020     19 Cx pipiens, Cx tarsalis   333         19  CO2
#> 11 Agency_1, Agency_2 2020     20 Cx pipiens, Cx tarsalis   197         14  CO2
#> 12 Agency_1, Agency_2 2020     21 Cx pipiens, Cx tarsalis    70         10  CO2
#> 13 Agency_1, Agency_2 2020     22              Cx pipiens    15          3  CO2
#> 14           Agency_1 2019      9 Cx pipiens, Cx tarsalis    26          7  CO2
#> 15           Agency_1 2019     10 Cx pipiens, Cx tarsalis    12          3  CO2
#> 16           Agency_2 2019     11             Cx tarsalis    17         10  CO2
#> 17 Agency_1, Agency_2 2019     12 Cx pipiens, Cx tarsalis   607         16  CO2
#> 18 Agency_1, Agency_2 2019     13 Cx pipiens, Cx tarsalis  1206         12  CO2
#> 19 Agency_1, Agency_2 2019     14 Cx pipiens, Cx tarsalis  9117         15  CO2
#> 20 Agency_1, Agency_2 2019     15 Cx pipiens, Cx tarsalis  5833         14  CO2
#> 21 Agency_1, Agency_2 2019     16 Cx pipiens, Cx tarsalis   373         13  CO2
#> 22 Agency_1, Agency_2 2019     17 Cx pipiens, Cx tarsalis  1734         12  CO2
#> 23 Agency_1, Agency_2 2019     18 Cx pipiens, Cx tarsalis  1107         12  CO2
#> 24 Agency_1, Agency_2 2019     19 Cx pipiens, Cx tarsalis  5597          6  CO2
#> 25 Agency_1, Agency_2 2019     21 Cx pipiens, Cx tarsalis    21          5  CO2
#> 26 Agency_1, Agency_2 2018     10 Cx pipiens, Cx tarsalis   278         11  CO2
#> 27 Agency_1, Agency_2 2018     11 Cx pipiens, Cx tarsalis    84         13  CO2
#> 28 Agency_1, Agency_2 2018     12 Cx pipiens, Cx tarsalis    17         10  CO2
#> 29 Agency_1, Agency_2 2018     13 Cx pipiens, Cx tarsalis  3907         17  CO2
#> 30 Agency_1, Agency_2 2018     14 Cx pipiens, Cx tarsalis  3941         14  CO2
#> 31           Agency_2 2018     15 Cx pipiens, Cx tarsalis  2571          9  CO2
#> 32 Agency_1, Agency_2 2018     16 Cx pipiens, Cx tarsalis  2153         16  CO2
#> 33 Agency_1, Agency_2 2018     17 Cx pipiens, Cx tarsalis   315         17  CO2
#> 34           Agency_1 2018     18 Cx pipiens, Cx tarsalis   171         14  CO2
#> 35 Agency_1, Agency_2 2018     19 Cx pipiens, Cx tarsalis   146         14  CO2
#> 36 Agency_1, Agency_2 2018     20 Cx pipiens, Cx tarsalis   159         16  CO2
#> 37           Agency_1 2018     21 Cx pipiens, Cx tarsalis    32          6  CO2
#> 38 Agency_1, Agency_2 2017      9 Cx pipiens, Cx tarsalis    41         10  CO2
#> 39 Agency_1, Agency_2 2017     10 Cx pipiens, Cx tarsalis   363         16  CO2
#> 40 Agency_1, Agency_2 2017     11 Cx pipiens, Cx tarsalis   208         18  CO2
#> 41 Agency_1, Agency_2 2017     12 Cx pipiens, Cx tarsalis   151         18  CO2
#> 42 Agency_1, Agency_2 2017     13             Cx tarsalis   917         19  CO2
#> 43 Agency_1, Agency_2 2017     14 Cx pipiens, Cx tarsalis   134         12  CO2
#> 44 Agency_1, Agency_2 2017     15 Cx pipiens, Cx tarsalis  2730         15  CO2
#> 45 Agency_1, Agency_2 2017     16 Cx pipiens, Cx tarsalis  4757         22  CO2
#> 46 Agency_1, Agency_2 2017     17 Cx pipiens, Cx tarsalis  6334         21  CO2
#> 47 Agency_1, Agency_2 2017     18 Cx pipiens, Cx tarsalis  1174         10  CO2
#> 48 Agency_1, Agency_2 2017     19 Cx pipiens, Cx tarsalis   181         22  CO2
#> 49 Agency_1, Agency_2 2017     20 Cx pipiens, Cx tarsalis   186         26  CO2
#> 50 Agency_1, Agency_2 2017     21 Cx pipiens, Cx tarsalis    57         18  CO2
#> 51           Agency_1 2016      8              Cx pipiens     5          2  CO2
#> 52           Agency_1 2016      9             Cx tarsalis    22          3  CO2
#> 53           Agency_1 2016     10 Cx pipiens, Cx tarsalis    85         17  CO2
#> 54           Agency_1 2016     11 Cx pipiens, Cx tarsalis    89         18  CO2
#> 55 Agency_1, Agency_2 2016     12 Cx pipiens, Cx tarsalis    97         20  CO2
#> 56 Agency_1, Agency_2 2016     13 Cx pipiens, Cx tarsalis  1652         22  CO2
#> 57 Agency_1, Agency_2 2016     14 Cx pipiens, Cx tarsalis  1821         18  CO2
#> 58 Agency_1, Agency_2 2016     15 Cx pipiens, Cx tarsalis   559         21  CO2
#> 59 Agency_1, Agency_2 2016     16 Cx pipiens, Cx tarsalis   982         24  CO2
#> 60 Agency_1, Agency_2 2016     17 Cx pipiens, Cx tarsalis  1550         18  CO2
#> 61 Agency_1, Agency_2 2016     18 Cx pipiens, Cx tarsalis   674         16  CO2
#> 62 Agency_1, Agency_2 2016     19             Cx tarsalis   103         10  CO2
#> 63 Agency_1, Agency_2 2016     20 Cx pipiens, Cx tarsalis    14         10  CO2
#> 64           Agency_1 2016     21             Cx tarsalis    42          2  CO2
#>    Abundance
#> 1       3.00
#> 2      16.67
#> 3      16.20
#> 4     316.50
#> 5      71.53
#> 6      28.58
#> 7      43.05
#> 8     207.33
#> 9      24.62
#> 10     17.53
#> 11     14.07
#> 12      7.00
#> 13      5.00
#> 14      3.71
#> 15      4.00
#> 16      1.70
#> 17     37.94
#> 18    100.50
#> 19    607.80
#> 20    416.64
#> 21     28.69
#> 22    144.50
#> 23     92.25
#> 24    932.83
#> 25      4.20
#> 26     25.27
#> 27      6.46
#> 28      1.70
#> 29    229.82
#> 30    281.50
#> 31    285.67
#> 32    134.56
#> 33     18.53
#> 34     12.21
#> 35     10.43
#> 36      9.94
#> 37      5.33
#> 38      4.10
#> 39     22.69
#> 40     11.56
#> 41      8.39
#> 42     48.26
#> 43     11.17
#> 44    182.00
#> 45    216.23
#> 46    301.62
#> 47    117.40
#> 48      8.23
#> 49      7.15
#> 50      3.17
#> 51      2.50
#> 52      7.33
#> 53      5.00
#> 54      4.94
#> 55      4.85
#> 56     75.09
#> 57    101.17
#> 58     26.62
#> 59     40.92
#> 60     86.11
#> 61     42.12
#> 62     10.30
#> 63      1.40
#> 64     21.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 = NULL, trap = NULL, separate_by = NULL)

Arguments


getAbundanceAnomaly(sample_collections,
                    interval = "Biweek",
                    target_year = 2020,
                    species = c("Cx tarsalis", "Cx pipiens"),
                    trap = "CO2",
                    separate_by  = "species") 
#>    Biweek     Species             Agency Year Count TrapEvents Trap Abundance
#> 1      10  Cx pipiens Agency_1, Agency_2 2020    12          4  CO2      3.00
#> 2      11 Cx tarsalis           Agency_2 2020   100          6  CO2     16.67
#> 3      12  Cx pipiens           Agency_2 2020    74          5  CO2     14.80
#> 4      12 Cx tarsalis           Agency_1 2020     7          5  CO2      1.40
#> 5      13  Cx pipiens Agency_1, Agency_2 2020   802         14  CO2     57.29
#> 6      13 Cx tarsalis Agency_1, Agency_2 2020  3629         14  CO2    259.21
#> 7      14  Cx pipiens Agency_1, Agency_2 2020   553         19  CO2     29.11
#> 8      14 Cx tarsalis Agency_1, Agency_2 2020   806         19  CO2     42.42
#> 9      15  Cx pipiens Agency_1, Agency_2 2020   336         19  CO2     17.68
#> 10     15 Cx tarsalis           Agency_1 2020   207         19  CO2     10.89
#> 11     16  Cx pipiens           Agency_1 2020    72         19  CO2      3.79
#> 12     16 Cx tarsalis Agency_1, Agency_2 2020   746         19  CO2     39.26
#> 13     17  Cx pipiens           Agency_2 2020   238          6  CO2     39.67
#> 14     17 Cx tarsalis Agency_1, Agency_2 2020  1006          6  CO2    167.67
#> 15     18  Cx pipiens Agency_1, Agency_2 2020   236         16  CO2     14.75
#> 16     18 Cx tarsalis Agency_1, Agency_2 2020   158         16  CO2      9.88
#> 17     19  Cx pipiens           Agency_1 2020    10         19  CO2      0.53
#> 18     19 Cx tarsalis Agency_1, Agency_2 2020   323         19  CO2     17.00
#> 19     20  Cx pipiens Agency_1, Agency_2 2020   152         14  CO2     10.86
#> 20     20 Cx tarsalis Agency_1, Agency_2 2020    45         14  CO2      3.21
#> 21     21  Cx pipiens Agency_1, Agency_2 2020    20         10  CO2      2.00
#> 22     21 Cx tarsalis           Agency_1 2020    50         10  CO2      5.00
#>    FiveYearAvg      YearsInAverage  Delta
#> 1     2.897500 2016,2017,2018,2019   3.54
#> 2     4.295000 2016,2017,2018,2019 288.13
#> 3     2.172500 2016,2017,2018,2019 581.24
#> 4    11.047500 2016,2017,2018,2019 -87.33
#> 5     6.353333      2016,2018,2019 801.73
#> 6   108.655000 2016,2017,2018,2019 138.56
#> 7     5.820000 2016,2017,2018,2019 400.17
#> 8   244.590000 2016,2017,2018,2019 -82.66
#> 9    14.560000 2016,2017,2018,2019  21.43
#> 10  213.172500 2016,2017,2018,2019 -94.89
#> 11    4.765000 2016,2017,2018,2019 -20.46
#> 12  100.332500 2016,2017,2018,2019 -60.87
#> 13   26.452500 2016,2017,2018,2019  49.97
#> 14  111.237500 2016,2017,2018,2019  50.73
#> 15   13.557500 2016,2017,2018,2019   8.80
#> 16   52.440000 2016,2017,2018,2019 -81.16
#> 17    4.130000      2017,2018,2019 -87.17
#> 18  237.347500 2016,2017,2018,2019 -92.84
#> 19    4.926667      2016,2017,2018 120.43
#> 20    1.236667      2016,2017,2018 159.57
#> 21    2.246667      2017,2018,2019 -10.98
#> 22    6.737500 2016,2017,2018,2019 -25.79

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 = c(NULL), trap = c(NULL))

Arguments

getInfectionRate(sample_pools, 
                      interval = "Week",
                      target_disease = "WNV",
                      pt_estimate = "mle", 
                      scale = 1000,
                      species = c("Cx pipiens", "Cx tarsalis"),
                      trap = c("CO2"),
                      separate_by="species", wide = FALSE )
#> # A tibble: 198 × 9
#> # Groups:   Year, Week [118]
#>     Year  Week Agency   Species     Trap  Disease InfectionRate LowerCI UpperCI
#>    <dbl> <dbl> <chr>    <chr>       <chr> <chr>           <dbl>   <dbl>   <dbl>
#>  1  2016    18 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#>  2  2016    18 Agency_1 Cx tarsalis CO2   WNV                 0       0       0
#>  3  2016    19 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#>  4  2016    19 Agency_1 Cx tarsalis CO2   WNV                 0       0       0
#>  5  2016    20 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#>  6  2016    21 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#>  7  2016    22 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#>  8  2016    22 Agency_1 Cx tarsalis CO2   WNV                 0       0       0
#>  9  2016    23 Agency_1 Cx pipiens  CO2   WNV                 0       0       0
#> 10  2016    23 Agency_1 Cx tarsalis CO2   WNV                 0       0       0
#> # ℹ 188 more rows

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: \(Vector Index = Infection Rate * Abundance\)

Usage

getVectorIndex(collections, pools, interval, , target_disease, pt_estimate,species=NULL, trap = NULL,)

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

Note: Years from pools and collections data must overlap

getVectorIndex(sample_collections, 
               sample_pools,
               interval = "Biweek",
               target_disease = "WNV",
               pt_estimate = "bc-mle",
               species = c("Cx tarsalis"), 
               trap =  c("CO2"),
               wide = FALSE)
#>    Year Biweek                      Agency     Species Trap TrapEvents Count
#> 1  2016      9                    Agency_1 Cx tarsalis  CO2          3    22
#> 2  2016     10                    Agency_1 Cx tarsalis  CO2         17    22
#> 3  2016     11                    Agency_1 Cx tarsalis  CO2         18    15
#> 4  2016     12           Agency_2,Agency_1 Cx tarsalis  CO2         20    11
#> 5  2016     13  Agency_2,Agency_1,Agency_2 Cx tarsalis  CO2         22  1594
#> 6  2016     14           Agency_2,Agency_1 Cx tarsalis  CO2         18  1530
#> 7  2016     15           Agency_2,Agency_1 Cx tarsalis  CO2         21   439
#> 8  2016     16           Agency_2,Agency_1 Cx tarsalis  CO2         24   944
#> 9  2016     17           Agency_2,Agency_1 Cx tarsalis  CO2         18  1168
#> 10 2016     18           Agency_2,Agency_1 Cx tarsalis  CO2         16   267
#> 11 2016     19           Agency_2,Agency_1 Cx tarsalis  CO2         10   103
#> 12 2016     20                    Agency_1 Cx tarsalis  CO2         10     1
#> 13 2016     21                    Agency_1 Cx tarsalis  CO2          2    42
#> 14 2017      9           Agency_1,Agency_2 Cx tarsalis  CO2         10    36
#> 15 2017     10           Agency_2,Agency_1 Cx tarsalis  CO2         16   331
#> 16 2017     11           Agency_2,Agency_1 Cx tarsalis  CO2         18   171
#> 17 2017     12           Agency_2,Agency_1 Cx tarsalis  CO2         18    95
#> 18 2017     13           Agency_2,Agency_1 Cx tarsalis  CO2         19   917
#> 19 2017     14           Agency_2,Agency_1 Cx tarsalis  CO2         12   120
#> 20 2017     15           Agency_2,Agency_1 Cx tarsalis  CO2         15  2721
#> 21 2017     16           Agency_2,Agency_1 Cx tarsalis  CO2         22  4437
#> 22 2017     17           Agency_2,Agency_1 Cx tarsalis  CO2         21  5777
#> 23 2017     18           Agency_2,Agency_1 Cx tarsalis  CO2         10  1081
#> 24 2017     19           Agency_2,Agency_1 Cx tarsalis  CO2         22    78
#> 25 2017     20           Agency_2,Agency_1 Cx tarsalis  CO2         26    63
#> 26 2017     21           Agency_2,Agency_1 Cx tarsalis  CO2         18     5
#> 27 2018     10           Agency_2,Agency_1 Cx tarsalis  CO2         11   250
#> 28 2018     11           Agency_2,Agency_1 Cx tarsalis  CO2         13    67
#> 29 2018     12           Agency_2,Agency_1 Cx tarsalis  CO2         10    13
#> 30 2018     13           Agency_2,Agency_1 Cx tarsalis  CO2         17  3871
#> 31 2018     14           Agency_2,Agency_1 Cx tarsalis  CO2         14  3922
#> 32 2018     15  Agency_2,Agency_1,Agency_2 Cx tarsalis  CO2          9  2114
#> 33 2018     16           Agency_2,Agency_1 Cx tarsalis  CO2         16  2140
#> 34 2018     17           Agency_2,Agency_1 Cx tarsalis  CO2         17    74
#> 35 2018     18           Agency_2,Agency_1 Cx tarsalis  CO2         14   129
#> 36 2018     19           Agency_2,Agency_1 Cx tarsalis  CO2         14   147
#> 37 2018     20                    Agency_1 Cx tarsalis  CO2         16    19
#> 38 2018     21                    Agency_1 Cx tarsalis  CO2          6    26
#> 39 2019      9                    Agency_1 Cx tarsalis  CO2          7    19
#> 40 2019     10                    Agency_1 Cx tarsalis  CO2          3     2
#> 41 2019     11           Agency_1,Agency_2 Cx tarsalis  CO2         10    17
#> 42 2019     12           Agency_2,Agency_1 Cx tarsalis  CO2         16   593
#> 43 2019     13           Agency_2,Agency_1 Cx tarsalis  CO2         12  1042
#> 44 2019     14           Agency_2,Agency_1 Cx tarsalis  CO2         15  9050
#> 45 2019     15           Agency_2,Agency_1 Cx tarsalis  CO2         14  5820
#> 46 2019     16           Agency_2,Agency_1 Cx tarsalis  CO2         13   350
#> 47 2019     17           Agency_2,Agency_1 Cx tarsalis  CO2         12  1208
#> 48 2019     18           Agency_2,Agency_1 Cx tarsalis  CO2         12   910
#> 49 2019     19           Agency_1,Agency_2 Cx tarsalis  CO2          6  5552
#> 50 2019     20                    Agency_1 Cx tarsalis  CO2         NA    NA
#> 51 2019     21                    Agency_1 Cx tarsalis  CO2          5     7
#> 52 2020     11           Agency_1,Agency_2 Cx tarsalis  CO2          6   100
#> 53 2020     12                    Agency_1 Cx tarsalis  CO2          5     7
#> 54 2020     13           Agency_2,Agency_1 Cx tarsalis  CO2         14  3629
#> 55 2020     14           Agency_2,Agency_1 Cx tarsalis  CO2         19   807
#> 56 2020     15           Agency_2,Agency_1 Cx tarsalis  CO2         19   209
#> 57 2020     16           Agency_2,Agency_1 Cx tarsalis  CO2         19   746
#> 58 2020     17           Agency_2,Agency_1 Cx tarsalis  CO2          6  1006
#> 59 2020     18           Agency_2,Agency_1 Cx tarsalis  CO2         16   158
#> 60 2020     19           Agency_2,Agency_1 Cx tarsalis  CO2         19   324
#> 61 2020     20           Agency_2,Agency_1 Cx tarsalis  CO2         14    45
#> 62 2020     21                    Agency_1 Cx tarsalis  CO2         10    50
#>    Abundance Disease InfectionRate VectorIndex
#> 1       7.33     WNV      0.000000     0.00000
#> 2       1.29     WNV      0.000000     0.00000
#> 3       0.83     WNV      0.000000     0.00000
#> 4       0.55     WNV      0.000000     0.00000
#> 5      72.45     WNV      0.000000     0.00000
#> 6      85.00     WNV      0.000000     0.00000
#> 7      20.90     WNV      0.000000     0.00000
#> 8      39.33     WNV      1.504589    59.17549
#> 9      64.89     WNV      2.667568   173.09851
#> 10     16.69     WNV      2.853338    47.62222
#> 11     10.30     WNV      0.000000     0.00000
#> 12      0.10    <NA>            NA          NA
#> 13     21.00    <NA>            NA          NA
#> 14      3.60     WNV      0.000000     0.00000
#> 15     20.69     WNV      0.000000     0.00000
#> 16      9.50     WNV      0.000000     0.00000
#> 17      5.28     WNV      0.000000     0.00000
#> 18     48.26     WNV      0.000000     0.00000
#> 19     10.00     WNV      0.000000     0.00000
#> 20    181.40     WNV      0.000000     0.00000
#> 21    201.68     WNV      0.000000     0.00000
#> 22    275.10     WNV      9.563533  2630.92794
#> 23    108.10     WNV      3.797545   410.51461
#> 24      3.55     WNV      0.000000     0.00000
#> 25      2.42     WNV      9.096849    22.01438
#> 26      0.28    <NA>            NA          NA
#> 27     22.73    <NA>            NA          NA
#> 28      5.15     WNV      0.000000     0.00000
#> 29      1.30     WNV      0.000000     0.00000
#> 30    227.71     WNV      0.000000     0.00000
#> 31    280.14     WNV      0.000000     0.00000
#> 32    234.89     WNV      0.000000     0.00000
#> 33    133.75     WNV      5.199235   695.39768
#> 34      4.35     WNV      8.506157    37.00178
#> 35      9.21     WNV      3.307239    30.45967
#> 36     10.50     WNV      0.000000     0.00000
#> 37      1.19     WNV      0.000000     0.00000
#> 38      4.33    <NA>            NA          NA
#> 39      2.71     WNV      0.000000     0.00000
#> 40      0.67     WNV      0.000000     0.00000
#> 41      1.70     WNV      0.000000     0.00000
#> 42     37.06     WNV      0.000000     0.00000
#> 43     86.83     WNV      0.000000     0.00000
#> 44    603.33     WNV      0.000000     0.00000
#> 45    415.71     WNV      0.000000     0.00000
#> 46     26.92     WNV      0.000000     0.00000
#> 47    100.67     WNV      0.000000     0.00000
#> 48     75.83     WNV      0.000000     0.00000
#> 49    925.33     WNV     14.389489 13315.02630
#> 50        NA     WNV      0.000000          NA
#> 51      1.40     WNV      0.000000     0.00000
#> 52     16.67     WNV      0.000000     0.00000
#> 53      1.40     WNV      0.000000     0.00000
#> 54    259.21     WNV      0.000000     0.00000
#> 55     42.47     WNV      2.278167    96.75373
#> 56     11.00     WNV      5.290396    58.19436
#> 57     39.26     WNV      0.000000     0.00000
#> 58    167.67     WNV      3.314811   555.79440
#> 59      9.88     WNV      0.000000     0.00000
#> 60     17.05     WNV     16.936452   288.76651
#> 61      3.21     WNV      0.000000     0.00000
#> 62      5.00     WNV      0.000000     0.00000

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

getPoolsComparisionTable(
  sample_pools,
  interval = "Week",
  target_disease = "WNV"
)
#> # A tibble: 120 × 6
#> # Groups:   Year, Week [120]
#>     Year  Week Negative Confirmed Total `Percent Positive`
#>    <dbl> <dbl>    <int>     <int> <int>              <dbl>
#>  1  2016    18        3         0     3                  0
#>  2  2016    19        7         0     7                  0
#>  3  2016    20        1         0     1                  0
#>  4  2016    21        3         0     3                  0
#>  5  2016    22       12         0    12                  0
#>  6  2016    23        5         0     5                  0
#>  7  2016    24        8         0     8                  0
#>  8  2016    25        5         0     5                  0
#>  9  2016    26        1         0     1                  0
#> 10  2016    27        6         0     6                  0
#> # ℹ 110 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 = c("Cx tarsalis", "Cx pipiens"),
  trap = "CO2",
  separate_by = "species")

head(AbAnOutput)
#>               Agency Year Biweek     Species Count TrapEvents Trap Abundance
#> 1 Agency_1, Agency_2 2020     10  Cx pipiens    12          4  CO2      3.00
#> 2           Agency_2 2020     11 Cx tarsalis   100          6  CO2     16.67
#> 3           Agency_2 2020     12  Cx pipiens    74          5  CO2     14.80
#> 4           Agency_1 2020     12 Cx tarsalis     7          5  CO2      1.40
#> 5 Agency_1, Agency_2 2020     13  Cx pipiens   802         14  CO2     57.29
#> 6 Agency_1, Agency_2 2020     13 Cx tarsalis  3629         14  CO2    259.21

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

AbAnOutput %>%
  kbl() %>%
  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 = "")
Agency Year Biweek Species Count TrapEvents Trap Abundance
Agency_1, Agency_2 2020 10 Cx pipiens 12 4 CO2 3.00
Agency_2 2020 11 Cx tarsalis 100 6 CO2 16.67
Agency_2 2020 12 Cx pipiens 74 5 CO2 14.80
Agency_1 2020 12 Cx tarsalis 7 5 CO2 1.40
Agency_1, Agency_2 2020 13 Cx pipiens 802 14 CO2 57.29
Agency_1, Agency_2 2020 13 Cx tarsalis 3629 14 CO2 259.21
Agency_1, Agency_2 2020 14 Cx pipiens 553 19 CO2 29.11
Agency_1, Agency_2 2020 14 Cx tarsalis 806 19 CO2 42.42
Agency_1, Agency_2 2020 15 Cx pipiens 336 19 CO2 17.68
Agency_1 2020 15 Cx tarsalis 207 19 CO2 10.89
Agency_1 2020 16 Cx pipiens 72 19 CO2 3.79
Agency_1, Agency_2 2020 16 Cx tarsalis 746 19 CO2 39.26
Agency_2 2020 17 Cx pipiens 238 6 CO2 39.67
Agency_1, Agency_2 2020 17 Cx tarsalis 1006 6 CO2 167.67
Agency_1, Agency_2 2020 18 Cx pipiens 236 16 CO2 14.75
Agency_1, Agency_2 2020 18 Cx tarsalis 158 16 CO2 9.88
Agency_1 2020 19 Cx pipiens 10 19 CO2 0.53
Agency_1, Agency_2 2020 19 Cx tarsalis 323 19 CO2 17.00
Agency_1, Agency_2 2020 20 Cx pipiens 152 14 CO2 10.86
Agency_1, Agency_2 2020 20 Cx tarsalis 45 14 CO2 3.21
Agency_1, Agency_2 2020 21 Cx pipiens 20 10 CO2 2.00
Agency_1 2020 21 Cx tarsalis 50 10 CO2 5.00
Agency_1, Agency_2 2020 22 Cx pipiens 15 3 CO2 5.00
Agency_1 2019 9 Cx pipiens 7 7 CO2 1.00
Agency_1 2019 9 Cx tarsalis 19 7 CO2 2.71
Agency_1 2019 10 Cx pipiens 10 3 CO2 3.33
Agency_1 2019 10 Cx tarsalis 2 3 CO2 0.67
Agency_2 2019 11 Cx tarsalis 17 10 CO2 1.70
Agency_1, Agency_2 2019 12 Cx pipiens 14 16 CO2 0.88
Agency_1, Agency_2 2019 12 Cx tarsalis 593 16 CO2 37.06
Agency_1 2019 13 Cx pipiens 164 12 CO2 13.67
Agency_1, Agency_2 2019 13 Cx tarsalis 1042 12 CO2 86.83
Agency_2 2019 14 Cx pipiens 67 15 CO2 4.47
Agency_1, Agency_2 2019 14 Cx tarsalis 9050 15 CO2 603.33
Agency_1, Agency_2 2019 15 Cx pipiens 14 14 CO2 1.00
Agency_1, Agency_2 2019 15 Cx tarsalis 5819 14 CO2 415.64
Agency_1, Agency_2 2019 16 Cx pipiens 23 13 CO2 1.77
Agency_1, Agency_2 2019 16 Cx tarsalis 350 13 CO2 26.92
Agency_1, Agency_2 2019 17 Cx pipiens 526 12 CO2 43.83
Agency_1, Agency_2 2019 17 Cx tarsalis 1208 12 CO2 100.67
Agency_1, Agency_2 2019 18 Cx pipiens 197 12 CO2 16.42
Agency_1, Agency_2 2019 18 Cx tarsalis 910 12 CO2 75.83
Agency_1, Agency_2 2019 19 Cx pipiens 45 6 CO2 7.50
Agency_2 2019 19 Cx tarsalis 5552 6 CO2 925.33
Agency_2 2019 21 Cx pipiens 14 5 CO2 2.80
Agency_1 2019 21 Cx tarsalis 7 5 CO2 1.40
Agency_1 2018 10 Cx pipiens 28 11 CO2 2.55
Agency_1, Agency_2 2018 10 Cx tarsalis 250 11 CO2 22.73
Agency_2 2018 11 Cx pipiens 17 13 CO2 1.31
Agency_1, Agency_2 2018 11 Cx tarsalis 67 13 CO2 5.15
Agency_1, Agency_2 2018 12 Cx pipiens 4 10 CO2 0.40
Agency_1, Agency_2 2018 12 Cx tarsalis 13 10 CO2 1.30
Agency_1, Agency_2 2018 13 Cx pipiens 36 17 CO2 2.12
Agency_1, Agency_2 2018 13 Cx tarsalis 3871 17 CO2 227.71
Agency_1 2018 14 Cx pipiens 19 14 CO2 1.36
Agency_1, Agency_2 2018 14 Cx tarsalis 3922 14 CO2 280.14
Agency_2 2018 15 Cx pipiens 457 9 CO2 50.78
Agency_2 2018 15 Cx tarsalis 2114 9 CO2 234.89
Agency_1 2018 16 Cx pipiens 18 16 CO2 1.12
Agency_1, Agency_2 2018 16 Cx tarsalis 2135 16 CO2 133.44
Agency_1, Agency_2 2018 17 Cx pipiens 242 17 CO2 14.24
Agency_1, Agency_2 2018 17 Cx tarsalis 73 17 CO2 4.29
Agency_1 2018 18 Cx pipiens 43 14 CO2 3.07
Agency_1 2018 18 Cx tarsalis 128 14 CO2 9.14
Agency_1 2018 19 Cx pipiens 3 14 CO2 0.21
Agency_1, Agency_2 2018 19 Cx tarsalis 143 14 CO2 10.21
Agency_1, Agency_2 2018 20 Cx pipiens 140 16 CO2 8.75
Agency_1 2018 20 Cx tarsalis 19 16 CO2 1.19
Agency_1 2018 21 Cx pipiens 6 6 CO2 1.00
Agency_1 2018 21 Cx tarsalis 26 6 CO2 4.33
Agency_1 2017 9 Cx pipiens 5 10 CO2 0.50
Agency_2 2017 9 Cx tarsalis 36 10 CO2 3.60
Agency_1 2017 10 Cx pipiens 32 16 CO2 2.00
Agency_1, Agency_2 2017 10 Cx tarsalis 331 16 CO2 20.69
Agency_1, Agency_2 2017 11 Cx pipiens 37 18 CO2 2.06
Agency_1, Agency_2 2017 11 Cx tarsalis 171 18 CO2 9.50
Agency_1, Agency_2 2017 12 Cx pipiens 56 18 CO2 3.11
Agency_1, Agency_2 2017 12 Cx tarsalis 95 18 CO2 5.28
Agency_1, Agency_2 2017 13 Cx tarsalis 917 19 CO2 48.26
Agency_1, Agency_2 2017 14 Cx pipiens 14 12 CO2 1.17
Agency_1 2017 14 Cx tarsalis 120 12 CO2 10.00
Agency_1 2017 15 Cx pipiens 9 15 CO2 0.60
Agency_1, Agency_2 2017 15 Cx tarsalis 2721 15 CO2 181.40
Agency_1, Agency_2 2017 16 Cx pipiens 320 22 CO2 14.55
Agency_1, Agency_2 2017 16 Cx tarsalis 4437 22 CO2 201.68
Agency_1, Agency_2 2017 17 Cx pipiens 557 21 CO2 26.52
Agency_1, Agency_2 2017 17 Cx tarsalis 5777 21 CO2 275.10
Agency_1 2017 18 Cx pipiens 93 10 CO2 9.30
Agency_1, Agency_2 2017 18 Cx tarsalis 1081 10 CO2 108.10
Agency_1, Agency_2 2017 19 Cx pipiens 103 22 CO2 4.68
Agency_1, Agency_2 2017 19 Cx tarsalis 78 22 CO2 3.55
Agency_1, Agency_2 2017 20 Cx pipiens 123 26 CO2 4.73
Agency_1, Agency_2 2017 20 Cx tarsalis 63 26 CO2 2.42
Agency_1, Agency_2 2017 21 Cx pipiens 53 18 CO2 2.94
Agency_2 2017 21 Cx tarsalis 4 18 CO2 0.22
Agency_1 2016 8 Cx pipiens 5 2 CO2 2.50
Agency_1 2016 9 Cx tarsalis 22 3 CO2 7.33
Agency_1 2016 10 Cx pipiens 63 17 CO2 3.71
Agency_1 2016 10 Cx tarsalis 22 17 CO2 1.29
Agency_1 2016 11 Cx pipiens 74 18 CO2 4.11
Agency_1 2016 11 Cx tarsalis 15 18 CO2 0.83
Agency_1, Agency_2 2016 12 Cx pipiens 86 20 CO2 4.30
Agency_1, Agency_2 2016 12 Cx tarsalis 11 20 CO2 0.55
Agency_1, Agency_2 2016 13 Cx pipiens 72 22 CO2 3.27
Agency_1, Agency_2 2016 13 Cx tarsalis 1580 22 CO2 71.82
Agency_1, Agency_2 2016 14 Cx pipiens 293 18 CO2 16.28
Agency_1, Agency_2 2016 14 Cx tarsalis 1528 18 CO2 84.89
Agency_1 2016 15 Cx pipiens 123 21 CO2 5.86
Agency_1, Agency_2 2016 15 Cx tarsalis 436 21 CO2 20.76
Agency_1, Agency_2 2016 16 Cx pipiens 39 24 CO2 1.62
Agency_1, Agency_2 2016 16 Cx tarsalis 943 24 CO2 39.29
Agency_1, Agency_2 2016 17 Cx pipiens 382 18 CO2 21.22
Agency_1, Agency_2 2016 17 Cx tarsalis 1168 18 CO2 64.89
Agency_1, Agency_2 2016 18 Cx pipiens 407 16 CO2 25.44
Agency_1, Agency_2 2016 18 Cx tarsalis 267 16 CO2 16.69
Agency_1, Agency_2 2016 19 Cx tarsalis 103 10 CO2 10.30
Agency_1, Agency_2 2016 20 Cx pipiens 13 10 CO2 1.30
Agency_1 2016 20 Cx tarsalis 1 10 CO2 0.10
Agency_1 2016 21 Cx tarsalis 42 2 CO2 21.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", "Species","Trap Type","Trap Events", "Abundance"))