knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ecopaR - an R package for parasite ecology

Installation

You can install and attach the development version of ecopaR like so:

if(!require(devtools)){
    install.packages("devtools")
}

if(!require(ecopaR)){
    devtools::install_github("ralphmp/ecopaR")
}

library(ecopaR)

Linux users need to install the following packages before installing devtools (ex. Debian): libcurl4-openssl-dev libssl-dev libfontconfig1-dev libxml2-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev

Examples:

library(ecopaR)
library(tidyverse)

birdticks data:

attach(birdticks)
str(birdticks)
head(birdticks)

Basic functions:

prevalence(ticks)
abundance(ticks)
intensity(ticks)

Aggregation indexes:

var_mean(ticks)
k_negative_binomial(ticks)
k_negative_binomial_inverse(ticks)
discrepancy(ticks)
Please, see note about k_negative_binomial functions before use.

Combining with R functions:

birdticks %>% 
  group_by(birds) %>% 
    summarise(
      Prevalence = prevalence(ticks)[1],
      Abundance = abundance(ticks)[1],
      Intensity = intensity(ticks)[1]) %>% 
      head()

Prevalence graph:

birdticks %>% 
  group_by(birds) %>% 
  summarise(
    Prevalence = prevalence(ticks)[1]) -> gg

graph <- ggplot(gg, aes(x = birds, y = Prevalence)) + geom_bar(stat = "identity", fill="turquoise4")
graph + coord_flip()

Intensity graph:

birdticks %>% 
  group_by(birds) %>% 
  summarise(
    Intensity = intensity(ticks)[1],
    Standard_Deviation = intensity(ticks)[2]) -> gg

graph <- ggplot(gg, aes(x = birds, y = Intensity$Mean.Intensity)) + geom_bar(stat = "identity", fill = "turquoise4" , position=position_dodge()) +
geom_errorbar(aes(ymin = ifelse(Intensity$Mean.Intensity - Standard_Deviation$Standard.Deviation < 0, 0, Intensity$Mean.Intensity - Standard_Deviation$Standard.Deviation), ymax = Intensity$Mean.Intensity + Standard_Deviation$Standard.Deviation), width = 0, position=position_dodge(.9))

graph + scale_fill_brewer(palette="Dark2") + coord_flip() 

Hydric stress functions:

saturation_deficit(80, 25)

saturation_deficit_bulb(wet_bulb = 22, dry_bulb = 26)


ralphmp/ecopaR documentation built on May 27, 2023, 3:50 p.m.