-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOCSdata_analysis.Rmd
91 lines (73 loc) · 2.74 KB
/
OCSdata_analysis.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
---
title: "OCSdata_analysis"
author: "Michael Breshock"
date: "9/20/2021"
output: html_document
editor_options:
chunk_output_type: console
---
```{r}
library(Visualize.CRAN.Downloads)
library(packageRank)
library(ggplot2)
library(tidyverse)
```
```{r}
# retrieve data
packageData <- retrievePckgData("OCSdata", "2021-03-01")
# select 1st element of the list
totalDownloads <- packageData[[1]]
# call the plotting fn, with default value of device --> PDF
staticPlots(totalDownloads)
interactivePlots(totalDownloads, nbrPlts = 1, mytitle = paste("OCSdata Package Download Counts"))
```
```{r}
downloads = cranDownloads(packages = "OCSdata", from = "2021-03-01", to = Sys.Date())
downloads = tibble(downloads$cranlogs.data) %>%
mutate(day = as.numeric(c(1:length(date))))
downloads
```
```{r}
theme_set(theme_minimal() + theme(axis.text = element_text(size = 11, color = "black"),
axis.title = element_text(size = 12, color = "black"),
plot.title = element_text(hjust = .5))
)
```
```{r}
p = ggplot(downloads, aes(x = day, y = count)) + geom_point(size = 2)
spline_down = as.data.frame(spline(downloads$day, downloads$count))
p + geom_line(spline_down, mapping = aes(x = x, y = y),
color = "#4B9B81",
linetype = "dashed", size = 1) +
labs(x = "Number of Days (since release)", y = "Number of Downloads",
title = "Number of Downloads per Day Since Release")
```
```{r}
ggplot(downloads, aes(x = day, y = cumulative)) +
geom_line(size = 2, color = "#4B9B81") +
labs(x = "Number of Days (since release)", y = "Total Downloads",
title = "Cumulative Number of Downloads Since Release")
```
```{r}
theme_set(theme_linedraw() +
theme(axis.text = element_text(size = 11,
color = "black"),
axis.title = element_text(size = 12,
color = "black"),
plot.title = element_text(size = 14,
color = "black",
hjust = .5))
)
```
```{r interactive elements}
counts = c(88,43,40,5)
type = c("All", "Multiple Choice", "Fill in the Chunk",
"Fill in the Blank")
exercises = tibble(counts, type)
ggplot(exercises, aes(x = reorder(type, -counts), y = counts, fill = type)) +
geom_col(color = "black") + scale_fill_viridis_d() +
labs(x = "Exercise Type", y = "Count", title = "Number of Interactive Exercises Implemented to Case Studies") +
guides(fill = "none") +
theme(axis.text.x = element_text(angle = 60, vjust = 0.5)) +
geom_text(aes(label = paste0(counts)), vjust = -.5) + ylim(0,100)
```