diff --git a/README.Rmd b/README.Rmd index 06f868b..e15f38b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -4,12 +4,15 @@ output: github_document -```{r, include = FALSE} +```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", - out.width = "100%" + out.width = "100%", + #echo = FALSE, + warning = FALSE, + message = FALSE ) ``` @@ -36,23 +39,20 @@ devtools::install_github("Knicey/stglyphs") This is an example which displays seasonal mins and maxes in temperature from NOAA across the US: -```{r data prep} +```{r} library(stglpyhs) -library(dplyr) library(ggplot2) -library(lubridate) +library(dplyr, warn.conflicts = FALSE) stations_grouped <- stations |> group_by(month, name, long, lat) |> summarise( avgmin = mean(tmin, na.rm = TRUE), avgmax = mean(tmax, na.rm = TRUE) - ) |> - ungroup() -#TODO: Accommodate for xend aesthetic (required in geom_segment) + ) ``` -```{r example} +```{r} ggplot(data = stations_grouped) + geom_sf(data = mainland_us, color = "white") + ggthemes::theme_map() + @@ -76,6 +76,7 @@ ggplot(data = stations_grouped) + This is another example that shows flight cancellations from the airports that have the most flight cancellations: ```{r} +library(lubridate, warn.conflicts = FALSE) flights_grouped <- flights |> mutate( month = month(FL_DATE), diff --git a/README.md b/README.md index 6cd473f..80f8d65 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,18 @@ - # stglpyhs -[![R-CMD-check](https://github.com/Knicey/stglyphs/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Knicey/stglyphs/actions/workflows/R-CMD-check.yaml) -[![Codecov test -coverage](https://codecov.io/gh/Knicey/stglyphs/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Knicey/stglyphs?branch=master) +[![R-CMD-check](https://github.com/Knicey/stglyphs/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Knicey/stglyphs/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/Knicey/stglyphs/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Knicey/stglyphs?branch=master) -The goal of stglpyhs is to introduce new ways of visualizing -spatio-temporal data and in particular analyzing across multivariate -seasonal data. The existing cubble package implements glyph maps in the -form of line graphs. This project seeks to expand this functionality to -segment plots to visualize multivariable data better and analyze -seasonal trends. +The goal of stglpyhs is to introduce new ways of visualizing spatio-temporal data and in particular analyzing across multivariate seasonal data. The existing cubble package implements glyph maps in the form of line graphs. This project seeks to expand this functionality to segment plots to visualize multivariable data better and analyze seasonal trends. ## Installation -You can install the development version of stglpyhs from -[GitHub](https://github.com/) with: +You can install the development version of stglpyhs from [GitHub](https://github.com/) with: ``` r # install.packages("devtools") @@ -30,38 +21,19 @@ devtools::install_github("Knicey/stglyphs") ## Example -This is an example which displays seasonal mins and maxes in temperature -from NOAA across the US: +This is an example which displays seasonal mins and maxes in temperature from NOAA across the US: ``` r library(stglpyhs) -library(dplyr) -#> -#> Attaching package: 'dplyr' -#> The following objects are masked from 'package:stats': -#> -#> filter, lag -#> The following objects are masked from 'package:base': -#> -#> intersect, setdiff, setequal, union library(ggplot2) -library(lubridate) -#> -#> Attaching package: 'lubridate' -#> The following objects are masked from 'package:base': -#> -#> date, intersect, setdiff, union +library(dplyr, warn.conflicts = FALSE) stations_grouped <- stations |> group_by(month, name, long, lat) |> summarise( avgmin = mean(tmin, na.rm = TRUE), avgmax = mean(tmax, na.rm = TRUE) - ) |> - ungroup() -#> `summarise()` has grouped output by 'month', 'name', 'long'. You can override -#> using the `.groups` argument. -#TODO: Accommodate for xend aesthetic (required in geom_segment) + ) ``` ``` r @@ -82,16 +54,14 @@ ggplot(data = stations_grouped) + y_minor = avgmin, yend_minor = avgmax) ) -#> Warning: Unknown or uninitialised column: `linewidth`. -#> Warning: Unknown or uninitialised column: `size`. ``` - + -This is another example that shows flight cancellations from the -airports that have the most flight cancellations: +This is another example that shows flight cancellations from the airports that have the most flight cancellations: ``` r +library(lubridate, warn.conflicts = FALSE) flights_grouped <- flights |> mutate( month = month(FL_DATE), @@ -106,10 +76,6 @@ flights_grouped <- flights |> max = max(total_flights), min = min(total_flights), ) -#> `summarise()` has grouped output by 'ORIGIN', 'month', 'year', 'longitude'. You -#> can override using the `.groups` argument. -#> `summarise()` has grouped output by 'ORIGIN', 'month', 'longitude'. You can -#> override using the `.groups` argument. ``` ``` r @@ -130,8 +96,6 @@ ggplot(data = flights_grouped) + y_minor = min, yend_minor = max) ) -#> Warning: Unknown or uninitialised column: `linewidth`. -#> Warning: Unknown or uninitialised column: `size`. ``` - + diff --git a/docs/articles/GeomSegmentGlyph.html b/docs/articles/GeomSegmentGlyph.html index d2afaf2..811b18e 100644 --- a/docs/articles/GeomSegmentGlyph.html +++ b/docs/articles/GeomSegmentGlyph.html @@ -165,31 +165,15 @@

Monthly Temperatures Across the US

Furthermore, there are options for y-scaling that include centering the glyph vertically on the station location.

-
-ggplot(data = grouped) +
-  geom_sf(data = mainland_us, color = "white") +
-  ggthemes::theme_map() +
-  geom_point(aes(x = long, y = lat)) +
-  geom_segment_glyph(
-    x_scale = rescale11x,
-    y_scale = rescale01y,
-    width = 2,
-    height = 3,
-    aes(
-    x_major = long, 
-    y_major = lat, 
-    x_minor = month, 
-    y_minor = avgmin, 
-    yend_minor = avgmax)
-    ) 

These rescaling past examples have all been made with global rescaling enabled (default) which results in the glyphs being differently sized according to their values relative to each other. Turning off global rescaling allows all glpyhs to rescale within their own individual values and produce glyphs that sized more evenly.

-
-ggplot(data = grouped) +
+
+
+ggplot(data = grouped) +
   geom_sf(data = mainland_us, color = "white") +
   ggthemes::theme_map() +
   geom_point(aes(x = long, y = lat)) +
@@ -205,9 +189,7 @@ 

Monthly Temperatures Across the US x_minor = month, y_minor = avgmin, yend_minor = avgmax) - ) -#> Warning: Unknown or uninitialised column: `linewidth`. -#> Warning: Unknown or uninitialised column: `size`.

+ )

diff --git a/docs/articles/GeomSegmentGlyph_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/GeomSegmentGlyph_files/figure-html/unnamed-chunk-6-1.png index a52d903..4fb57b8 100644 Binary files a/docs/articles/GeomSegmentGlyph_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/GeomSegmentGlyph_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/index.html b/docs/index.html index 01cf1ca..ac91074 100644 --- a/docs/index.html +++ b/docs/index.html @@ -71,33 +71,15 @@

ExampleThis is an example which displays seasonal mins and maxes in temperature from NOAA across the US:

 library(stglpyhs)
-library(dplyr)
-#> 
-#> Attaching package: 'dplyr'
-#> The following objects are masked from 'package:stats':
-#> 
-#>     filter, lag
-#> The following objects are masked from 'package:base':
-#> 
-#>     intersect, setdiff, setequal, union
 library(ggplot2)
-library(lubridate)
-#> 
-#> Attaching package: 'lubridate'
-#> The following objects are masked from 'package:base':
-#> 
-#>     date, intersect, setdiff, union
+library(dplyr, warn.conflicts = FALSE)
 
 stations_grouped <- stations |>
   group_by(month, name, long, lat) |>
   summarise(
     avgmin = mean(tmin, na.rm = TRUE),
     avgmax = mean(tmax, na.rm = TRUE)
-  ) |>
-  ungroup() 
-#> `summarise()` has grouped output by 'month', 'name', 'long'. You can override
-#> using the `.groups` argument.
-#TODO: Accommodate for xend aesthetic (required in geom_segment)
+ )

 ggplot(data = stations_grouped) +
   geom_sf(data = mainland_us, color = "white") +
@@ -115,13 +97,12 @@ 

Example x_minor = month, y_minor = avgmin, yend_minor = avgmax) - ) -#> Warning: Unknown or uninitialised column: `linewidth`. -#> Warning: Unknown or uninitialised column: `size`.

-

+ ) +

This is another example that shows flight cancellations from the airports that have the most flight cancellations:

-flights_grouped <- flights |>
+library(lubridate, warn.conflicts = FALSE)
+flights_grouped <- flights |>
   mutate(
     month = month(FL_DATE),
     year = year(FL_DATE)
@@ -134,11 +115,7 @@ 

Example summarise( max = max(total_flights), min = min(total_flights), - ) -#> `summarise()` has grouped output by 'ORIGIN', 'month', 'year', 'longitude'. You -#> can override using the `.groups` argument. -#> `summarise()` has grouped output by 'ORIGIN', 'month', 'longitude'. You can -#> override using the `.groups` argument.

+ )
 ggplot(data = flights_grouped) +
   geom_sf(data = mainland_us, color = "white") +
@@ -156,10 +133,8 @@ 

Example x_minor = month, y_minor = min, yend_minor = max) - ) -#> Warning: Unknown or uninitialised column: `linewidth`. -#> Warning: Unknown or uninitialised column: `size`.

-

+ ) +