import sf
Showing 1 of 36 files from the diff.
Other files ignored by Codecov
man/figures/README-ochRe-2.png
has changed.
docs/CODE_OF_CONDUCT.html
has changed.
docs/index.html
has changed.
docs/pkgdown.yml
has changed.
CODE_OF_CONDUCT.md
has changed.
docs/reference/ozmap_states.html
has changed.
docs/reference/ozmap.html
has changed.
docs/reference/abs-data.html
has changed.
docs/articles/index.html
is new.
docs/news/index.html
has changed.
docs/reference/figures/README-ochRe-2.png
has changed.
docs/articles/ozmaps_files/figure-html/ozmap-1.png
has changed.
man/abs-data.Rd
has changed.
man/ozmap.Rd
has changed.
docs/404.html
has changed.
docs/reference/ozmap_data.html
has changed.
docs/reference/oz.html
has changed.
docs/authors.html
has changed.
cran-comments.md
has changed.
NAMESPACE
has changed.
docs/articles/ozmaps_files/figure-html/ochRe-2.png
has changed.
docs/articles/ozmaps.html
is new.
README.Rmd
has changed.
README.md
has changed.
vignettes/ozmaps.Rmd
has changed.
DESCRIPTION
has changed.
docs/reference/index.html
has changed.
docs/reference/ozmaps-package.html
has changed.
NEWS.md
has changed.
docs/articles/ozmaps_files/figure-html/ochRe-1.png
has changed.
.travis.yml
has changed.
tests/testthat/Rplots.pdf
has changed.
docs/reference/ozmap-2.png
has changed.
@@ -8,23 +8,30 @@
Loading
8 | 8 | #' See `abs_ste` for more detailed versions from the Australian Bureau of Statistics. |
|
9 | 9 | #' An example is 'abs_ste' which means 'State and Territory', and |
|
10 | 10 | #' so is a more detailed version of 'states'. |
|
11 | + | #' |
|
12 | + | #' `ozmap()` uses the sf package to plot, but does so by only plotting the |
|
13 | + | #' geometry rather than every colum, and leaves the plot region ready for overplotting with other |
|
14 | + | #' data. |
|
11 | 15 | #' @param x name of data set to use, default is `ozmap_country` |
|
12 | 16 | #' @param add add to existing plot, `FALSE` by default |
|
13 | 17 | #' @param ... arguments passed to ... |
|
14 | 18 | #' @seealso ozmap_data |
|
15 | 19 | #' @return the data set used, in 'sf' format |
|
16 | 20 | #' @export |
|
17 | - | #' |
|
21 | + | #' @importFrom sf st_geometry |
|
22 | + | #' @importFrom graphics plot |
|
18 | 23 | #' @examples |
|
19 | 24 | #' ozmap() |
|
20 | - | #' ozmap("country") |
|
21 | - | #' ozmap("abs_ced") ## commonwealth (national) electoral divisions |
|
25 | + | #' ozmap("country", lwd = 6) |
|
26 | + | #' ozmap("abs_ced", add = TRUE, border = "firebrick") ## commonwealth (national) electoral divisions |
|
22 | 27 | ozmap <- function(x = "states", ..., add = FALSE) { |
|
23 | 28 | if ("states" %in% names(list(...))) { |
|
24 | 29 | warning("states argument is deprecated, see 'oz::oz()' function") |
|
25 | 30 | } |
|
26 | 31 | x <- ozmap_data(x, quiet = TRUE) |
|
27 | - | plot_sfc(x, add = add, ...) |
|
32 | + | ||
33 | + | ||
34 | + | plot(sf::st_geometry(x), add = add, ..., reset = FALSE) |
|
28 | 35 | invisible(x) |
|
29 | 36 | } |
|
30 | 37 |
@@ -113,58 +120,3 @@
Loading
113 | 120 | ozmap_abs_ste_data <- function(...){ |
|
114 | 121 | abs_ste |
|
115 | 122 | } |
|
116 | - | ||
117 | - | plot_bbox <- function(x, ...) { |
|
118 | - | xr <- x[c("xmin", "xmax")] |
|
119 | - | yr <- x[c("ymin", "ymax")] |
|
120 | - | plot(xr, yr, type = "n", axes = FALSE, xlab = "", ylab = "", ...) |
|
121 | - | } |
|
122 | - | ||
123 | - | ||
124 | - | ||
125 | - | ## from sf |
|
126 | - | # person(given = "Edzer", |
|
127 | - | # family = "Pebesma", |
|
128 | - | # role = c("ctb"), |
|
129 | - | # comment = c(ORCID = "0000-0001-8049-7069")) |
|
130 | - | #' @importFrom graphics plot polypath |
|
131 | - | plot_sfc <- function(x, y, ..., lty = 1, lwd = 1, col = NA, border = 1, add = FALSE, rule = "evenodd") { |
|
132 | - | # FIXME: take care of lend, ljoin, xpd, and lmitre |
|
133 | - | stopifnot(missing(y)) |
|
134 | - | geom <- x[[attr(x, "sf_column")]] |
|
135 | - | bb <- attr(geom, "bbox") |
|
136 | - | prj <- attr(geom, "crs")$proj4string |
|
137 | - | if (!"asp" %in% names(list(...))) { |
|
138 | - | asp <- 1 |
|
139 | - | if (grepl("longlat", prj) || grepl("4326", prj)) { |
|
140 | - | asp <- 1/cos(mean(bb[c("ymin", "ymax")]) * pi/180) |
|
141 | - | } |
|
142 | - | } else { |
|
143 | - | asp <- list(...)$asp |
|
144 | - | } |
|
145 | - | if (! add) |
|
146 | - | plot_bbox(bb, asp = asp) |
|
147 | - | x <- geom |
|
148 | - | lty = rep(lty, length.out = length(x)) |
|
149 | - | lwd = rep(lwd, length.out = length(x)) |
|
150 | - | col = rep(col, length.out = length(x)) |
|
151 | - | border = rep(border, length.out = length(x)) |
|
152 | - | #non_empty = ! st_is_empty(x) |
|
153 | - | lapply(seq_along(x), function(i) { |
|
154 | - | lapply(x[[i]], function(L) { |
|
155 | - | polypath(sf_p_bind(L), border = border[i], lty = lty[i], lwd = lwd[i], col = col[i], rule = rule) |
|
156 | - | })}) |
|
157 | - | invisible(NULL) |
|
158 | - | } |
|
159 | - | ||
160 | - | ||
161 | - | sf_p_bind <- function(lst) { |
|
162 | - | if (length(lst) == 1) |
|
163 | - | lst[[1]] |
|
164 | - | else { |
|
165 | - | ret = vector("list", length(lst) * 2 - 1) |
|
166 | - | ret[seq(1, length(lst) * 2 - 1, by = 2)] = lst # odd elements |
|
167 | - | ret[seq(2, length(lst) * 2 - 1, by = 2)] = NA # even elements |
|
168 | - | do.call(rbind, ret) # replicates the NA to form an NA row |
|
169 | - | } |
|
170 | - | } |
Files | Coverage |
---|---|
R | 100.00% |
Project Totals (2 files) | 100.00% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.