Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Class-Activity-3_JUNG.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: "class activity 3"
author: "Charles Lang"
date: "10/2/2018"
output: html_document
---

#Mapping aesthetic to data to = layer
```{r}
install.packages("ggplot2")
library(ggplot2)

ggplot(diamonds, aes(x = price, y = carat)) +
geom_point()
```

#Two layers
```{r}
ggplot(mpg, aes(reorder(class, hwy), hwy)) +
geom_jitter() +
geom_boxplot()
```

```{r}

#Plot count
ggplot(diamonds, aes(depth)) +
geom_histogram(aes(y = ..count..), binwidth=0.2) +
facet_wrap(~ cut) + xlim(50, 70)

#Plot density
ggplot(diamonds, aes(depth)) +
geom_histogram(aes(y = ..density..), binwidth=0.2) +
facet_wrap(~ cut) + xlim(50, 70)
```

```{r}
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point()

```

Can you create a line graph using the "economics_long" data set that shows change over time in "value01" for different categories of "variable"?

```{r}
economics_long <- economics_long

library(RColorBrewer)

display.brewer.all()
cols <- brewer.pal(n = 8, name = "Accent")
pal <- colorRampPalette(cols)

ggplot(economics_long, aes(x=date, y=value01, color = variable), group=variable) + geom_line()

```

If you would like to recreate the Minard graphic of Napoleon's Troops the code is below and the data is in this repo.

```{r}

ggplot(cities, aes(long, lat)) +
geom_path(aes(size = survivors, colour =
direction,
group = interaction(group, direction)), data =
troops) +
geom_text(aes(label = city), hjust = 0, vjust = 1,
size = 4)
# Polish appearance
last_plot() +
scale_x_continuous("", limits = c(24, 39)) +
scale_y_continuous("") +
scale_colour_manual(values = c("grey50","red"))
scale_size(c(1, 10))

```