electivity

Algorithms for electivity indices and measures of resource use versus availability, from Lechowicz (1982).

https://github.com/desiquintans/electivity

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.3%) to scientific vocabulary

Keywords

ecology electivity r r-package
Last synced: 9 months ago · JSON representation

Repository

Algorithms for electivity indices and measures of resource use versus availability, from Lechowicz (1982).

Basic Info
  • Host: GitHub
  • Owner: DesiQuintans
  • License: other
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 43.9 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
ecology electivity r r-package
Created almost 7 years ago · Last pushed almost 7 years ago
Metadata Files
Readme Contributing License

README.Rmd

---
title: "electivity: Algorithms for electivity indices and measures of resource use versus availability"
output: github_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

[![DOI](https://zenodo.org/badge/201148710.svg)](https://zenodo.org/badge/latestdoi/201148710)

Desi Quintans (2019). _electivity: Algorithms for Electivity Indices._ R package version 1.0.2. https://github.com/DesiQuintans/electivity

---

This package is essentially Lechowicz (1982) turned into an R package. It includes
all algorithms that were described therein plus the example data that
was provided for gypsy moth resource utilisation.

Lechowicz, M.J., 1982. The sampling characteristics of electivity indices.
Oecologia 52, 22–30. https://doi.org/10.1007/BF00349007

Users are encouraged to read the original paper before deciding which algorithm
is most useful for them. Lechowicz recommended Vanderploeg and Scavia's E* index
(implemented in this package as `vs_electivity()`) as "the single best, but not
perfect, electivity index" because "E* embodies a measure of the feeder's
perception of a food's value as a function of both its abundance and the
abundance of other food types present." In practice, he found that all indices
returned nearly identical rank orders of preferred hosts except for Strauss'
linear index (L).


## Installing

```{r echo=TRUE, eval=FALSE}
# Installing from CRAN (not yet!)
install.packages(electivity)

# Installing from GitHub
install.packages(remotes)
remotes::install_github("DesiQuintans/electivity")

library(electivity)
```

```{r echo=FALSE, message=FALSE, warning=FALSE}
library(electivity)
```


## Built-in datasets

```{r}
data(moth_distrib)  # Table 2 from Lechowicz (1982), raw data
data(moth_elect)    # Table 3 from Lechowicz (1982), calculated indices

head(moth_distrib)
head(moth_elect)
```


## Examples

### Calculating food preference for a single animal

```{r}
gypsy_moth_prefs <- vs_electivity(moth_distrib$r, moth_distrib$p)

names(gypsy_moth_prefs) <- moth_distrib$binomen

sort(gypsy_moth_prefs, decreasing = TRUE)
```

### Calculating food preference for many animals at many sites (Tidy approach)

```{r message=FALSE, warning=FALSE}
library(tidyr)
library(dplyr)
library(purrr)

# Example data
df <- tibble::tribble(
           ~snail,     ~site,      ~food, ~pieces_eaten, ~pieces_present,
           "Bert", "outside",   "Carrot",             3,               7,
           "Bert", "outside", "Broccoli",             3,               8,
           "Bert", "outside",     "Kale",             1,               1,
           "Bert",  "inside",   "Carrot",             5,              11,
           "Bert",  "inside", "Broccoli",             7,               3,
           "Bert",  "inside",     "Kale",             2,               4,
          "Ernie", "outside",   "Carrot",             6,               7,
          "Ernie", "outside", "Broccoli",             4,               8,
          "Ernie", "outside",     "Kale",             1,               1,
          "Ernie",  "inside",   "Carrot",             3,              11,
          "Ernie",  "inside", "Broccoli",             1,               3,
          "Ernie",  "inside",     "Kale",             4,               4
          )


prefs <- 
    df %>% 
    # Nest the data for each snail x site pair
    nest(-snail, -site) %>% 
    # Apply vs_electivity() (or any other function) to each nested dataframe
    mutate(score = map(data, ~ vs_electivity(.$pieces_eaten, .$pieces_present))) %>% 
    # Expand the result (score) into new rows
    unnest(score, data) %>% 
    # Omit unwanted columns
    select(-pieces_eaten, -pieces_present) %>% 
    # Turn the sites into columns that show electivity for each snail x food pair.
    spread(key = site, value = score)

knitr::kable(prefs, format = "markdown")
```


## Contributors

- Desi Quintans https://github.com/DesiQuintans

Contributions are welcome!

Owner

  • Name: Desi Quintans
  • Login: DesiQuintans
  • Kind: user

GitHub Events

Total
Last Year

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 25
  • Total Committers: 1
  • Avg Commits per committer: 25.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Desi Quintans s****e@d****m 25
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 1.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Poochican (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 209 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: electivity

Algorithms for Electivity Indices

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 209 Last month
Rankings
Forks count: 28.8%
Dependent packages count: 29.8%
Stargazers count: 31.7%
Dependent repos count: 35.5%
Average: 41.2%
Downloads: 80.4%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.4.0 depends
  • usethis >= 1.0.0 suggests
  • utils >= 3.4.2 suggests