export-prevR-method: Export an object of class prevR.

Description Usage Arguments Details See Also Examples

Description

This method could be used to export an object of class prevR in different formats (text, shapefile, dbase...)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## S4 method for signature 'prevR'
export(
  object,
  element,
  format,
  file,
  N = NULL,
  R = NULL,
  clusters.only = FALSE,
  ext = NULL,
  sep = NULL,
  dec = NULL,
  ...
)

Arguments

object

object of class prevR.

element

element to export: "clusters" or "boundary".

format

format: "dbf", "txt", csv", "csv2" or "shp" (unused if element="boundary").

file

file name without extension.

N

integer or list of integers setting elements of rings to export (unused if element="boundary").

R

integer or list of integers setting elements of rings to export (unused if element="boundary").

clusters.only

export only the slot clusters of object (unused if element="boundary")?

ext

coerce the extension of the export file (unused if element="boundary" or if format="shp").

sep

coerce the field separator string (unused if element="boundary" or if format="shp" or if format="dbf").

dec

coerce the string to use for decimal point (unused if element="boundary" or if format="shp" or if format="dbf").

...

additional arguments transmitted to rgdal::writeOGR(), foreign::write.dbf() or utils::write.table().

Details

If element="boundary", the slot boundary of object will be exported as a shapefile.

Otherwise, the slot clusters, merged with the slot rings, will be exporter.
See as.data.frame() for details on the use of the parameters of N, R et clusters.only.

format specifies the export format of the data frame returned by as.data.frame():

"shp" Shape File (require the package rgdal)
"dbf" DBASE format (extension: .dbf, require the package foreign)
"txt" tabulated text (extension: .txt)
"csv" 'comma separated values' (extension: .csv)
"csv2" CSV variant using a semicolon as field separator (extension: .csv)

ext could be used to coerce the extension of the output file, except for shapefile export, which will write four different files (.shp, .shx, .dbf and .prj).

The "txt" format uses by default a tabulation as field separator and a point "." for decimal point. The "csv" format uses a comma "," as field separator and a point "." as decimal point.
The "csv2" format is a variant using a semicolon ";" as field separator and a colon "," for decimal point, the Excel convention for CSV files in some Western European locales.
sep and dec could be used to coerce the field separator and the decimal point (together with the "txt" format).

See Also

maptools::writePolyShape, maptools::writePointsShape(), foreign::write.dbf(), utils::write.table().

Examples

1
2
3
4
5
6
7
8
  ## Not run: 
    export(fdhs, element="boundary", file="area")
    export(fdhs, element="clusters", format="shp", file="points")
    
    dhs <- rings(fdhs,N=c(100,300,500))
    export(dhs, element="clusters", format="csv", N=300, file="points")
  
## End(Not run)

prevR documentation built on Aug. 28, 2020, 5:08 p.m.