forked from core-methods-in-edm/class-activity-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintro-to-viz.Rmd
More file actions
74 lines (50 loc) · 2.32 KB
/
intro-to-viz.Rmd
File metadata and controls
74 lines (50 loc) · 2.32 KB
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
---
title: "intro to viz"
author: "Charles Lang"
date: "October 3, 2016"
output: html_document
---
#Input
```{r}
D1 <- read.csv("School_Demographics_and_Accountability_Snapshot_2006-2012.csv", header = TRUE, sep = ",")
D2 <- subset(D1, schoolyear == 20112012)
```
#Histograms
```{r}
hist()
hist(D2$frl_percent, breaks = 100)
hist(D2$frl_percent, breaks = c(0,10,20,80,100))
hist(D2$frl_percent, breaks = 100, ylim = c(0,30))
```
#Plots
```{r}
plot(D2$ell_num, D2$ctt_num)
plot(D2$ell_num ~ D2$ctt_num)
#Barplot
x <- c(1,3,2,7,6,4,4)
y <- c(2,4,2,3,2,4,3)
table1 <- table(x,y)
barplot(table1)
#Lineplot
D3 <- aggregate(D1, by = list(D1$schoolyear), FUN = mean)
plot(D3$schoolyear, D3$total_enrollment, type = "l", lty = "dashed")
#Boxplot
D5 <- subset(D1, DBN == "31R075")
D5 <- droplevels(D5)
boxplot(D5$total_enrollment ~ D5$Name)
```
#Pairs
```{r}
D4 <- D2[,c(5,6, 21:24)]
pairs(D4)
```
# Exercise
1. Create a simulated data set containing 100 students, each with a score from 1-100 representing performance in an educational game. The scores should tend to cluster around 75. Also, each student should be given a classification that reflects one of four interest groups: sport, music, nature, literature.
2. Using base R commands, draw a histogram of the scores. Change the breaks in your histogram until you think they best represent your data.
3. Create a new variable that groups the scores according to the breaks in your histogram.
4. Now using the colorbrewer package (RColorBrewer; http://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3) design a pallette and assign it to the groups in your data on the histogram.
5. Create a boxplot that visualizes the scores for each interest group and color each interest group a different color.
6. Now simulate a new variable that describes the number of logins that students made to the educational game. They should vary from 1-25.
7. Plot the relationships between logins and scores. Give the plot a title and color the dots according to interest group.
8. R contains several inbuilt data sets, one of these in called AirPassengers. Plot a line graph of the the airline passengers over time using this data set.
9. Using another inbuilt data set, Iris, plot the relationships between all of the variables in the data set. Which of these relationships is it appropraiet to run a correlation on?