Learn R Programming

MIAmaxent (version 0.4.0)

readData: Read in data object from files.

Description

readData reads in occurrence data in CSV file format and environmental data in ASCII raster file format and produces a data object which can be used as the starting point for the functions in this package. This function is intended to make reading in data easy for users familiar with the maxent.jar program. It is emphasized that important considerations for data preparation (e.g. cleaning, sampling bias removal, etc.) are not treated in this package and must be dealt with separately!

Usage

readData(occurrence, contEV = NULL, catEV = NULL, maxbkg = 10000,
  PA = FALSE, XY = FALSE)

Arguments

occurrence
Full pathway of the '.csv' file of occurrence data. The first column of the CSV should code occurrence (see Details), while the second and third columns should contain X and Y coordinates corresponding to the ASCII raster coordinate system. The first row is read as a header row.
contEV
Pathway to a directory containing continuous environmental variables in '.asc' file format.
catEV
Pathway to a directory containing categorical environmental variables in '.asc' file format.
maxbkg
Integer. Maximum number of grid cells randomly selected as unknown background points for the response variable. Default is 10,000. Irrelevant for presence/absence data (PA = TRUE) and ignored for presence-only data (PA = FALSE) if occurrence contains 'NA' values.
PA
Logical. Does occurrence represent presence/absence data? This argument affects how the values in occurrence are interpreted, and controls what type of data object is produced. See details.
XY
Logical. Include XY coordinates in the output. May be useful for spatial plotting. Note that coordinates included in the training data used to build the model will be treated as explanatory variables.

Value

Data frame with the Response Variable (RV) in the first column, and Explanatory Variables (EVs) in subsequent columns. When PA = FALSE, RV values are 1/NA, and when PA = TRUE, RV values are 1/0. With presence-only occurrence data, the returned output can be used as the data argument for plotFOP, deriveVars, selectDVforEV, selectEV, and plotResp. With presence/absence occurrence data, the returned output can be used as the data argument for testAUC. Output from readData can also be used as the data argument for plotResp2, and projectModel, but for these functions the values of RV are irrelevant.

Details

When occurrence represents presence-only data (PA = FALSE), all rows with values other than 'NA' in column 1 of the CSV file are treated as presence locations. If column 1 contains any values of 'NA', these rows are treated as the unknown background locations for the response variable. Thus, 'NA' can be used to specify a specific set of background locations if desired. Otherwise background points are randomly selected from the full extent of the raster cells which are not already included as presence locations. Only cells which contain data for all environmental variables are selected as background locations. When occurrence represents presence/absence data (PA = TRUE), rows with value '0' in column 1 of the CSV are treated as absence locations, rows with value 'NA' are excluded, and all other rows are treated as presences. The names of the ASCII raster files are used as the names of the explanatory variables, so these files should be uniquely named, and the names must not contain spaces, underscores, or colons. Underscores and colons are reserved to denote derived variables and interaction terms repectively. readData automatically replaces underscores with hyphens.

Examples

Run this code
## Not run: ------------------------------------
# dat <- readData(occurrence = "D:/path/to/occurrence/data.csv",
#    contEV = "D:/path/to/continuousEV/directory",
#    catEV = "D:/path/to/categoricalEV/directory", maxbkg = 100000, XY = TRUE)
## ---------------------------------------------

toydata_sp1po <- readData(system.file("extdata/sommerfeltia", "Sp1.csv", package = "MIAmaxent"),
   contEV = system.file("extdata/sommerfeltia", "EV_continuous", package = "MIAmaxent"))
toydata_sp1po

## Not run: ------------------------------------
# # From vignette:
# grasslandPO <- readData(
#    occurrence = system.file("extdata", "occurrence_PO.csv", package = "MIAmaxent"),
#    contEV = system.file("extdata", "EV_continuous", package = "MIAmaxent"),
#    catEV = system.file("extdata", "EV_categorical", package = "MIAmaxent"),
#    maxbkg = 20000)
# head(grasslandPO)
# 
# # From vignette:
# grasslandPA <- readData(
#    occurrence = system.file("extdata", "occurrence_PA.csv", package = "MIAmaxent"),
#    contEV = system.file("extdata", "EV_continuous", package = "MIAmaxent"),
#    catEV = system.file("extdata", "EV_categorical", package = "MIAmaxent"),
#    PA = TRUE, XY = TRUE)
# head(grasslandPA)
# tail(grasslandPA)
## ---------------------------------------------

Run the code above in your browser using DataLab