Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 72 lines (48 sloc) 2.88 KB
<!-- README.md is generated from README.Rmd. Please edit that file
knitr::knit('README.Rmd')
-->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
[![Travis-CI Build Status](https://travis-ci.org/mpio-be/rangeMapper.svg?branch=master)](https://travis-ci.org/mpio-be/rangeMapper)
[![Coverage Status](https://img.shields.io/codecov/c/github/mpio-be/rangeMapper/master.svg)](https://codecov.io/github/mpio-be/rangeMapper?branch=master)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/rangeMapper)](http://cran.r-project.org/package=rangeMapper)
[_rangeMapper_](http://onlinelibrary.wiley.com/doi/10.1111/j.1466-8238.2011.00739.x/full/) is a framework for the study of macroecological patterns of life-history traits.
### _rangeMapper_ in a nutshell
```{r,echo=FALSE,results='hide', message=FALSE,warning=FALSE, fig.width=10, fig.height=5}
require(rangeMapper); require(magrittr)
require(ggplot2)
require(rgdal)
breding_ranges = rgdal::readOGR(system.file(package = "rangeMapper", "extdata", "wrens", "vector_combined"), "wrens", verbose = FALSE)
breding_ranges = spTransform(breding_ranges, CRS('+proj=moll')) %>% rgeos::gBuffer(width = 0, byid = TRUE)
wrens_boundary = rgeos::gUnionCascaded(breding_ranges)
data(wrens)
d = subset(wrens, select = c('sci_name', 'body_mass', 'clutch_size') )
con = ramp("wrens.sqlite", gridSize = 150000, spdf = breding_ranges, biotab = d, ID = "sci_name",
FUN = "median", overwrite = TRUE)
```
* Datasets (i.e. maps) are retrieved from `sqlite` project files as objects inheriting from `SpatialPixels` or `data.table`. Maps can be plotted directly with `plot()`.
```{r,1, fig.cap="", echo=TRUE,results='hide', message=FALSE,warning=FALSE, fig.width=10, fig.height=5}
map = rangeMap.fetch(con, c('median_body_mass', 'median_clutch_size'), spatial = FALSE)
plot(map, boundary = wrens_boundary, ncol = 2 , outlierDetector = function(x) extremevalues::getOutliersI(x)$limit)
```
* The link between the assemblage level (i.e. the raster cell) and the species level (i.e. the data behind the raster cell) is kept explicit at all stages of the project.
`MAP`s are constructed based on `SQL` aggregate functions or statistical models build in R and can be based on arbitrary subsets defined at both species and assemblage levels.
```R
rangeMap.save(con, FUN = lmSlope, biotab = "life_history_traits",
biotrait = "body_mass", tableName = "slope_bm_cs",
formula = log(body_mass) ~ clutch_size,
subset = list(MAP_species_richness = "SR >= 5",
MAP_altitude = "altitude > 1000",
BIO_biotab = "Family = 'Troglodytidae'
AND clutch_size is not NULL") )
```
### Installation
```R
devtools::install_github("mpio-be/rangeMapper") # development.
install.packages("rangeMapper") # stable.
```