Learn R Programming

prevR (version 2.2)

as.prevR: 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")

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 observatio
boundary
object of class SpatialPolygons defining the studied area.
proj
projection of clusters coordinates used in data (longitude and latitude in decimal degrees by default).

Value

encoding

utf8

Details

Only "x", "y" "n" and "pos" are required in col. If "id" is not specified, a numzrical identifier will be automatically created. proj defines projection used by data. It could be a character string corresponding to a PROJ.4 projection (see http://trac.osgeo.org/proj/ for more details) or an object of class CRS{sp}. If the projection of boundary is defined in a slot called proj4string, boundary will be projected according to proj. If the slot proj4string is missing, boundary will be considered to be already in the same projection as proj. If boundary is not defined (NULL), a considered 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.

See Also

prevR-class, create.boundary, changeproj, import.dhs.

Examples

Run this code
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)

Run the code above in your browser using DataLab