# NOT RUN {
x <- "{ type: 'Point', coordinates: [10, 50] }"
# don't apply any function, identity essentially
lawn_coordeach(x)
# appply a function callback
lawn_coordeach(x, "z.length === 2")
lawn_coordeach(lawn_data$points_count, "z.length === 2")
z <- '{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"population": 200,
"name": "things"
},
"geometry": {
"type": "Point",
"coordinates": [-112.0372, 46.608058]
}
}, {
"type": "Feature",
"properties": {
"population": 600,
"name": "stuff"
},
"geometry": {
"type": "Point",
"coordinates": [-112.045955, 46.596264]
}
}
]
}'
lawn_coordeach(z)
lawn_coordeach(z, "z.reduce(function(a, b) { return a + b; }, 0)")
# }
Run the code above in your browser using DataLab