diff --git a/class-activity-3.Rmd b/class-activity-3.Rmd index d8dd1d6..c42ca73 100644 --- a/class-activity-3.Rmd +++ b/class-activity-3.Rmd @@ -1,7 +1,7 @@ --- title: "class activity 3" -author: "Charles Lang" -date: "10/2/2018" +author: "Qiyang(Minnie) Lin" +date: "10/1/2019" output: html_document --- @@ -11,7 +11,8 @@ install.packages("ggplot2") library(ggplot2) ggplot(diamonds, aes(x = price, y = carat)) + - geom_point() + geom_point() # + geom_point()meaning that you want to graph this type of graph + ``` #Two layers @@ -24,6 +25,7 @@ ggplot(mpg, aes(reorder(class, hwy), hwy)) + ```{r} #Plot count +diamonds ggplot(diamonds, aes(depth)) + geom_histogram(aes(y = ..count..), binwidth=0.2) + facet_wrap(~ cut) + xlim(50, 70) @@ -43,12 +45,28 @@ ggplot(mpg, aes(displ, hwy, color = class)) + 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 +ggplot(economics_long, aes(date, value01, group = variable, color = variable))+ + geom_line() + +#Plot date +#ggplot(economics_long, aes(date)) + +# geom_line(aes(y = value01) ) +# facet_wrap(~ variable) + +#plot var +#ggplot(economics_long, aes(variable)) + +# geom_line(aes(y = value01) ) +# facet_wrap(~ variable) ``` 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} +df1<-read.delim("cities.txt") +df2<-read.delim("troops.txt") +#cities<- merge.data.frame(df1, df2, by = c('long', 'lat')) ggplot(cities, aes(long, lat)) + geom_path(aes(size = survivors, colour = @@ -62,6 +80,6 @@ last_plot() + scale_x_continuous("", limits = c(24, 39)) + scale_y_continuous("") + scale_colour_manual(values = c("grey50","red")) + - scale_size(to = c(1, 10)) + scale_size(c(1, 10)) ```