Skip to content

Commit

Permalink
Closes #317 and #310
Browse files Browse the repository at this point in the history
  • Loading branch information
mine-cetinkaya-rundel committed May 31, 2024
1 parent c67dc04 commit bbdc078
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data-visualization.pdf
Binary file not shown.
25 changes: 8 additions & 17 deletions html/data-visualization.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ translation_list(sheet_name)
library(ggplot2)
```

```{r}
#| label: other-used-packages
#| include: false
library(maps)
```

To display values, map variables in the data to visual properties of the geom (**aesthetics**) like **size**, **color**, and **x** and **y** locations.

Complete the template below to build a graph.
Expand Down Expand Up @@ -264,17 +257,15 @@ j <- ggplot(df, aes(grp, fit, ymin = fit - se, ymax = fit + se))

### Two Variables - Maps

Draw the appropriate geometric object depending on the simple features present in the data.
`aes()` arguments: `map_id`, `alpha`, `color`, `fill`, `linetype`, `linewidth`.

```{r}
murder_data <- data.frame(
murder = USArrests$Murder,
state = tolower(rownames(USArrests))
)
map <- map_data("state")
k <- ggplot(murder_data, aes(fill = murder))
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))
ggplot(nc) +
geom_sf(aes(fill = AREA))
```

- `k + geom_map(aes(map_id = state), map = map) + expand_limits(x = map$long, y = map$lat)`: Draw polygons as a map. `aes()` arguments: `map_id`, `alpha`, `color`, `fill`, `linetype`, `linewidth`.

### Three Variables

```{r}
Expand Down Expand Up @@ -469,8 +460,8 @@ u <- d + geom_bar()
Transformed Cartesian coordinates.
Set `xtrans` and `ytrans` to the name of a window function.

- `π + coord_quickmap(); π + coord_map(projection = "ortho", orientation = c(41, -74, 0))`: `projection`, `xlim`, `ylim`.
Map projections from the **mapproj** packages (`mercator` (default), `azequalarea`, `lagrange`, etc.).
- `π + coord_sf()`: `xlim`, `ylim`, `crs`.
Ensures all layers use a common Coordinate Reference System.

## Position Adjustments

Expand Down
Binary file modified html/images/logo-ggplot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified keynotes/data-visualization.key
Binary file not shown.
Binary file modified pngs/data-visualization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bbdc078

Please sign in to comment.