This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathmaierucsb.Rmd
127 lines (90 loc) · 3.66 KB
/
maierucsb.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
title: "maierucsb"
author: "Mitchell Maier"
date: "January 19, 2016"
output:
html_document:
toc: true
toc_depth: 2
---
```{r setwd, echo=FALSE, warning=FALSE}
# set working directory if has child directory
dir_child = 'students'
if (dir_child %in% list.files()){
if (interactive()) {
# R Console
setwd(dir_child)
} else {
# knitting
knitr::opts_knit$set(root.dir=dir_child)
}
}
```
## **Content**
I am interested in reducing waste and inefficient products that create environmental and toxilogical harm. I am also interested in GIS and visualizing geographic data in useful and interesting ways (*especially data related to global deforestation right now as it is a large component of my thesis project*)
In this class I will be looking into pollution statistics... [see my group site here](https://github.com/pollute/pollute.github.io)
## **Techniques**
I think collaborative model building and interactive plots and maps will be very useful for my project now and research in the future.
## **Data**
For now, in the name of practice, I'll illustrate some data on how far Derrick Rose, point gaurd for the Chicago Bulls who has been horrendously riddled by knee injuries, has fallen statistically from his great 2010-2011 campaign.
Here is his shot chart from 2010-2011

Here is his shot chart so far from 2015-2016

As can be seen, Derrick Rose's statistical climb has regressed... This decline can aslo be seen in his overall [stats](http://stats.nba.com/player/#!/201565/)... The future looks tragically quite dim for the former MVP.
```{r Data, echo=FALSE, warning=FALSE, message=FALSE,}
## Data Wrangling
# load libraries
library(readr);
library(dplyr);
# read csv
a = read_csv(file='data/maierucsb_data.csv')
#filter out data
a %T>%
select(Season,DRtg,ORtg) %>%
mutate(CombineRtg = ORtg+DRtg) %>%
summarise("Average Combined Rating"= mean(CombineRtg),
"Minimum Combined Rating"= min(CombineRtg),
"Maximum Combined Rating"= max(CombineRtg))
# output barplot
b=select(a,Season,PTS,TRB,AST,STL,BLK,TOV)
barplot(as.matrix(b[2:7]),cex.names=0.9, xlab="Statistical Category",ylab="Per 100 Possession Averages",legend=a$Season,beside=TRUE)
```
##Assignment4
```{r insertco2, echo=FALSE, message=FALSE, results='hide'}
library(readxl) # install.packages('readxl')
# url = 'http://edgar.jrc.ec.europa.eu/news_docs/CO2_1970-2014_dataset_of_CO2_report_2015.xls'
xls = '../data/co2_europa.xls'
# print(getwd())
# if (!file.exists(xls)){
# download.file(url, xls)
# }
co2class = read_excel(xls, skip=12)
```
```{r widetolong, echo=FALSE}
library(dplyr)
library(tidyr)
gatherco2=co2class%>%
gather('year','emissions',2:46);
table1=slice(gatherco2,1:3);
library(knitr)
kable(table1,digits=0,caption='wide to long format of emmissions')
```
```{r topfiveco2, echo=FALSE}
topfive=gatherco2 %>%
mutate(year = as.numeric(as.character(year))) %>%
filter(Country != 'World' & Country != 'EU28' & year == 2014) %>%
arrange(desc(emissions)) %>%
slice(1:5)
kable(topfive,digits=0,caption="top five emitting countries in 2014",col.names=c('Country','Year','Emissions'))
```
```{r totalemissions, echo=FALSE}
totalemit=gatherco2 %>%
mutate(year = as.numeric(as.character(year))) %>%
filter(Country != 'World' & Country != 'EU28') %>%
group_by(Country) %>%
summarise(totalemissions = sum(emissions))%>%
arrange(desc(totalemissions)) %>%
slice(1:5)
kable(totalemit,digits=0,caption="top five emitting countries from 1970-2014",col.names=c('Country','Total Emissions'))
```