library("knitr") hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set(output = function(x, options) { lines <- options$output.lines if (is.null(lines)) { return(hook_output(x, options)) # pass to default hook } x <- unlist(strsplit(x, "\n")) more <- "..." if (length(lines)==1) { # first n lines if (length(x) > lines) { # truncate the output, but add .... x <- c(head(x, lines), more) } } else { x <- c(if (abs(lines[1])>1) more else NULL, x[lines], if (length(x)>lines[abs(length(lines))]) more else NULL ) } # paste these lines together x <- paste(c(x, ""), collapse = "\n") hook_output(x, options) }) knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
randgeo
is a no dependency R package for generating random lat/long positions, or
random WKT or GeoJSON points or polygons.
The benefit of no dependencies is that it can easily be used in other packages without any pain. e.g., you may want to show examples in your package but you don't want a heavy dependency just for examples.
This package is adapted from Javascript's https://github.com/tmcw/geojson-random but with modifications.
Stable randgeo
version from CRAN
install.packages("randgeo")
Or, the development version from Github
devtools::install_github("ropensci/randgeo")
library("randgeo")
rg_position()
Many positions
rg_position(10)
Random position within a bounding box
rg_position(bbox = c(50, 50, 60, 60))
A single point
wkt_point()
Many points
wkt_point(count = 10)
Within a bounding box
wkt_point(bbox = c(50, 50, 60, 60))
The fmt
parameter controls how many decimal points
wkt_point() wkt_point(fmt = 10)
wkt_polygon()
Adjust number of vertices (Default: 10)
wkt_polygon(num_vertices = 4)
Adjust maximum number of decimal degrees latitude or longitude that a vertex can reach out of the center of the Polygon (Default: 10)
wkt_polygon(max_radial_length = 5)
Within a bounding box
wkt_polygon(bbox = c(-130, 50, -120, 60))
A single point
geo_point()
Many points
geo_point(count = 10)
Within a bounding box
geo_point(bbox = c(50, 50, 60, 60))
geo_polygon()
Adjust number of vertices (Default: 10)
geo_polygon(num_vertices = 4)
Adjust maximum number of decimal degrees latitude or longitude that a vertex can reach out of the center of the Polygon (Default: 10)
geo_polygon(max_radial_length = 5)
Within a bounding box
geo_polygon(bbox = c(-130, 50, -120, 60))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.