as.prevR {prevR}R Documentation

Create an object of class prevR.

Description

This function creates an object of class prevR from a data frame.

Usage

as.prevR(data, col, boundary = NULL, proj = "+proj=longlat +datum=WGS84")

Arguments

data

data frame, each line corresponding to an observed cluster.

col

vector identifying the columns of data to use.
clusters columns names are fixed:

  • "id" (optional) cluster's identifier.

  • "x" cluster's longitude.

  • "y" cluster's latitude.

  • "n" number of valid observations in the cluster.

  • "pos" number of positive cases in the cluster.

  • "wn" (optional) sum of observations weight.

  • "wpos" (optional) sum of positive cases weight.

  • "c.type" (optional) type of cluster (used only by plot()).

See examples.

boundary

object of class sf::sf defining the studied area.

proj

projection of clusters coordinates used in data (longitude and latitude in decimal degrees by default). One of (i) character: a string accepted by GDAL, (ii) integer, a valid EPSG value (numeric), or (iii) an object of class crs, see sf::st_crs().

Details

Only "x", "y" "n" and "pos" are required in col. If "id" is not specified, a numerical identifier will be automatically created.

If boundary is not defined (NULL), a rectangle corresponding to minimal and maximal coordinates of data will be used.

boundary could be the result of the function create.boundary().

It's not possible to change projection of data with as.prevR(). Use changeproj() instead.

Value

Object of class prevR

See Also

prevR class, create.boundary(), changeproj(), import.dhs().

Examples

col <- c(
  id = "cluster",
  x = "x",
  y = "y",
  n = "n",
  pos = "pos",
  c.type = "residence",
  wn = "weighted.n",
  wpos = "weighted.pos"
)
dhs <- as.prevR(fdhs.clusters, col, fdhs.boundary)

str(dhs)
print(dhs)

[Package prevR version 5.0.0 Index]