All Projects → mkearney → Hexagon

mkearney / Hexagon

◀️⏹▶️ R package for creating hexagon shaped xy data frames.

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Hexagon

Cld2
R Wrapper for Google's Compact Language Detector 2
Stars: ✭ 34 (-15%)
Mutual labels:  r-package, rstats
Rtimicropem
😷 R Package for the Analysis of RTI MicroPEM Output Files 😷
Stars: ✭ 9 (-77.5%)
Mutual labels:  r-package, rstats
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (-37.5%)
Mutual labels:  r-package, rstats
Patentsview
An R client to the PatentsView API
Stars: ✭ 18 (-55%)
Mutual labels:  r-package, rstats
Sofa
easy R interface to CouchDB
Stars: ✭ 30 (-25%)
Mutual labels:  r-package, rstats
Restez
😴 📂 Create and Query a Local Copy of GenBank in R
Stars: ✭ 22 (-45%)
Mutual labels:  r-package, rstats
Spenv
Combine environmental and spatial data
Stars: ✭ 8 (-80%)
Mutual labels:  r-package, rstats
Proj
⛔️ [DEPRECATED] R wrapper for proj4js
Stars: ✭ 5 (-87.5%)
Mutual labels:  r-package, rstats
Wellknown
WKT <-> GeoJSON
Stars: ✭ 15 (-62.5%)
Mutual labels:  r-package, rstats
Originr
Species origin data from the web in R
Stars: ✭ 13 (-67.5%)
Mutual labels:  r-package, rstats
Chr
🔤 Lightweight R package for manipulating [string] characters
Stars: ✭ 18 (-55%)
Mutual labels:  r-package, rstats
Cricketdata
International cricket data for men and women, Tests, ODIs and T20s
Stars: ✭ 35 (-12.5%)
Mutual labels:  r-package, rstats
Skimr
A frictionless, pipeable approach to dealing with summary statistics
Stars: ✭ 889 (+2122.5%)
Mutual labels:  r-package, rstats
Rdhs
API Client and Data Munging for the Demographic and Health Survey Data
Stars: ✭ 22 (-45%)
Mutual labels:  r-package, rstats
Icpsrdata
Reproducible data downloads from the ICPSR data archive
Stars: ✭ 7 (-82.5%)
Mutual labels:  r-package, rstats
Rnaturalearthdata
to hold data used by rnaturalearth
Stars: ✭ 8 (-80%)
Mutual labels:  r-package, rstats
Vitae
R Markdown Résumés and CVs
Stars: ✭ 627 (+1467.5%)
Mutual labels:  r-package, rstats
Egretci
A bootstrap method for estimating uncertainty of water quality trends
Stars: ✭ 5 (-87.5%)
Mutual labels:  r-package, rstats
Ieeer
Search IEEE publications in R
Stars: ✭ 12 (-70%)
Mutual labels:  r-package, rstats
Graphql
Bindings to libgraphqlparser for R
Stars: ✭ 31 (-22.5%)
Mutual labels:  r-package, rstats

hexagon

lifecycle

R package for creating hexagon shaped xy data frames.

Installation

To get the current development version from Github:

## install devtools package if it's not already
if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}

## install dev version of hexagon from github
devtools::install_github("mkearney/hexagon")

## load rtweet package
library(hexagon)

Usage

## create hexagon xy data frame using argument defaults
hex1 <- hexdf()

## plot outline of hexagon
with(hex1, plot(x, y, type = "l"))

 
## create larger hexagon to the lower right with a different midpoint
hex2 <- hexdf(2, mid = c(2.5, -2))

## load ggplot2
library(ggplot2)

## plot both hex1 and hex2 objects using ggplot2
ggplot(hex1, aes(x, y)) +
  geom_polygon(fill = "blue") +
  geom_polygon(data = hex2, fill = "red")

 

Example

Create a package sticker

## generate some data to plot
n <- 43
den <- ceiling(n / 5)
x <- seq(-.525, .465, length.out = n) + rep(c(-.005, .005), ceiling(n/2))[1:n]
y <- seq(-.1, .1, length.out = ceiling(n / den))
y <- rep(c(y, rev(y)), ceiling(n / den))[1:n] + seq(.0, .45, length.out = n)
z <- c(rep("a", ceiling(n / den)), rep("b", ceiling(n / den)))
z <- rep(z, ceiling(n / den))[1:n]
pts <- data.frame(x, y, z)

## create base plot
p_ <- ggplot(hex1, aes(x, y)) +
  geom_polygon(fill = "#114466", colour = "#001030", size = 1) +
  geom_point(data = pts, aes(fill = z, colour = z), shape = 21, size = 1.75) +
  scale_fill_manual(values = c("#8CFF00", "#cc00ff")) +
  scale_colour_manual(values = c("#0A2200", "#110033")) +
  annotate("text", 0, -.36, label = "hexagon",
    colour = "white", size = 8, fontface = "bold") +
  coord_fixed(ratio = 1, expand = TRUE) +
  coord_cartesian(xlim = range(hex1$x), ylim = range(hex1$y)) +
  theme_void()

## adjust margin to maximize sticker
t <- 6
r <- 5
b <- 9
l <- 8
p <- p_ +
  theme(legend.position = "none",
    plot.margin = margin(-t, -r, -b, -l, unit = "pt"))

#view plot in device
p

## save plot with sticker dimensions
#ggsave("hexagon-logo.png", p, width = 1.73, height = 2,
#  units = "in", bg = "transparent")

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].