Skip to contents

Use segmented regression to create a species-area relationship (SAR) plot. The X axis represents log(island area) and the Y axis represents log(number of species)

Usage

create_SAR(occurrences, npsi = 1, visualize = FALSE)

Arguments

occurrences

The dataframe output by ssarp::find_areas() (or if using a custom dataframe, ensure that it has the following columns: specificEpithet, areas)

npsi

The maximum number of breakpoints to estimate for model selection. Default: 1

visualize

(boolean) Whether the plot should be displayed when the function is called. Default: FALSE

Value

A list of 5 including: the summary output, the regression object for the best-fit model, the aggregated dataframe used to create the plot, the AIC scores used in model selection, and all of the models created in model selection

Details

If the user would prefer to create their own plot of the ssarp::create_SAR() output, the aggDF element of the returned list includes the raw points from the plot created here. They can be accessed as demonstrated in the Examples section.

Examples

# The GBIF key for the Anolis genus is 8782549
# Read in example dataset filtered from:
#  dat <- rgbif::occ_search(taxonKey = 8782549,
#                           hasCoordinate = TRUE,
#                           limit = 10000)
dat <- read.csv(system.file("extdata",
                            "ssarp_Example_Dat.csv",
                            package = "ssarp"))
#> Warning: file("") only supports open = "w+" and open = "w+b": using the former
#> Error in read.table(file = file, header = header, sep = sep, quote = quote,     dec = dec, fill = fill, comment.char = comment.char, ...): no lines available in input
land <- find_land(occurrences = dat)
#> Error: object 'dat' not found
areas <- find_areas(occs = land)
#> Error: object 'land' not found

seg <- create_SAR(occurrences = areas,
                  npsi = 1,
                  visualize = FALSE)
#> Error: object 'areas' not found
plot(seg)
#> Error: object 'seg' not found
summary <- seg$summary
#> Error: object 'seg' not found
model_object <- seg$segObj
#> Error: object 'seg' not found
points <- seg$aggDF
#> Error: object 'seg' not found