Learn R Programming

lawn (version 0.1.7)

lawn_quantile: Calculate quantiles

Description

Takes a data-FeatureCollection, a property name, set of percentiles and returns a quantile array

Usage

lawn_quantile(input, field, percentiles, lint = FALSE)

Arguments

input
Set of Features
field
The property in input from which to retrieve quantile values
percentiles
An Array of percentiles on which to calculate quantile values
lint
(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

An array of the break values

See Also

Other classification: lawn_jenks, lawn_nearest, lawn_reclass

Examples

Run this code
pts <- '{
 "type": "FeatureCollection",
 "features": [
   {
     "type": "Feature",
     "properties": {
       "population": 5
     },
     "geometry": {
       "type": "Point",
       "coordinates": [5, 5]
     }
   }, {
     "type": "Feature",
     "properties": {
       "population": 40
     },
     "geometry": {
       "type": "Point",
       "coordinates": [1, 3]
     }
   }, {
     "type": "Feature",
     "properties": {
       "population": 80
     },
     "geometry": {
       "type": "Point",
       "coordinates": [14, 2]
     }
   }, {
     "type": "Feature",
     "properties": {
       "population": 90
     },
     "geometry": {
       "type": "Point",
       "coordinates": [13, 1]
     }
   }, {
     "type": "Feature",
     "properties": {
       "population": 100
     },
     "geometry": {
       "type": "Point",
       "coordinates": [19, 7]
     }
   }
 ]
}'
lawn_quantile(pts, 'population', c(25, 50, 75, 99))
lawn_quantile(pts, 'population', c(25, 50, 75, 95))
lawn_quantile(pts, 'population', c(25, 50, 75))
lawn_quantile(pts, 'population', c(1, 50, 99.9))

Run the code above in your browser using DataLab