calc_moransI: Calculate Moran's I from a data frame

Description Usage Arguments Value Examples

View source: R/spatial_stats.R

Description

Computes spatial autocorrelation for a single sample and single variable (sssv) from a data frame with three columns (longitude, latitude, and measurement). Uses inverse of distance between points in Moran's I calculation.

Usage

1
2
3
4
5
6
calc_moransI(
  df_sssv,
  lon_col = "longitude",
  lat_col = "latitude",
  meas_col = "Measurement"
)

Arguments

df_sssv

data frame with spatial measurements of a single sample and single variable

lon_col

character string, column name for longitude column

lat_col

character string, column name for latitude column

meas_col

character string, column name for measurement column

Value

numeric, the Moran's I (spatial autocorrelation)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
example_data <- data.frame(
  lon = runif(n = 10, min = -90, max = -85),
  lat = runif(n = 10, min = 45, max = 46),
  meas = rnorm(10)
)
calc_moransI(example_data, lon_col = "lon", lat_col = "lat", meas_col = "meas")

peter_lake_data <- flame_data %>%
  dplyr::filter(Lake == "R" & Date == as.Date("2019-07-22")) %>%
  dplyr::select(latitude, longitude, BGApc_ugL_tau)
calc_moransI(peter_lake_data, meas_col = "BGApc_ugL_tau")

cbuelo/tvsews documentation built on Jan. 21, 2022, 1:31 a.m.