boB Rudis 5 years ago
parent
commit
7eb1aa20ae
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      R/aaa.R
  2. 4
      R/statebins-manual.R
  3. 6
      R/statebins.R

1
R/aaa.R

@ -27,3 +27,4 @@ state_coords <- structure(list(abbrev = c("AL", "AK", "AZ", "AR", "CA", "CO",
.Names = c("abbrev", "state", "col", "row"),
class = "data.frame", row.names = c(NA, -54L))
state_coords <- state_coords[order(state_coords$state),]

4
R/statebins-manual.R

@ -79,11 +79,12 @@ statebins_manual <- function(state_data, state_col="state", color_col="color",
st.dat <- merge(state_coords, state_data, by.x=merge.x, by.y=state_col, all.y=TRUE)
gg <- ggplot(st.dat, aes_string(x="col", y="row", label="abbrev"))
gg <- gg + geom_tile(aes_string(fill="color"))
gg <- gg + geom_tile(aes_string(fill=color_col))
gg <- gg + geom_tile(color=state_border_col, aes_string(fill="color"),
size=2, show.legend=FALSE)
gg <- gg + geom_text(color=text_color, size=font_size)
gg <- gg + scale_y_reverse()
if (is.null(labels)) {
gg <- gg + scale_fill_manual(values=unique(st.dat[,color_col]))
legend_position = "none"
@ -91,6 +92,7 @@ statebins_manual <- function(state_data, state_col="state", color_col="color",
gg <- gg + scale_fill_manual(values=unique(st.dat[,color_col]),
labels=labels, name=legend_title)
}
gg <- gg + coord_equal()
gg <- gg + labs(x=NULL, y=NULL, title=NULL)
gg <- gg + theme_bw()

6
R/statebins.R

@ -66,9 +66,9 @@ statebins <- function(state_data, state_col="state", value_col="value",
palette <- match.arg(trimws(tolower(palette)), c("brewer", "viridis"))
if (breaks <= 0 | breaks > 10) {
stop("'breaks' must be between 0 & 10")
}
# if (breaks <= 0 | breaks > 10) {
# stop("'breaks' must be between 0 & 10")
# }
if (!title_position %in% c("", "top", "bottom")) {
stop("'title_position' must be either blank, 'top' or 'bottom'")

Loading…
Cancel
Save