forked from rstudio/learnr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instructions.Rmd
160 lines (95 loc) · 5.08 KB
/
instructions.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
title: "Welcome to the DSI learnR resources"
output: html_notebook
editor_options:
chunk_output_type: inline
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk (or the green triangle on the top left of the grey chunk), or by placing your cursor inside the grey box (which is a code chunk) and pressing *Ctrl+Shift+Enter*.
```{r}
library(learnr)
```
## Hello
You already did the tutorial contained in `ex-setup-r` to download and setup r and RStudio.
To give you a simple idea of what these tutorials do on a local machine, let's run the following line.
```{r learnr_hi}
runlearnr("hello/hello.Rmd","r/passr.Rmd")
```
## An important setup step do not skip over this heading!
We also need to install some packages...this is not very elegant, but it goes over all the files in this project and looks for Rmds. Then it reads each line of the Rmds, and extracts references to library calls. I've already done this, so I've pasted the output into one line for you to run. You can modify this if you don't want to install all the packages at once (it may take a while).
```{r setup}
# rmd <- list.files(path = ".", recursive = T) %>%
# str_subset("\\.Rmd$")
# rmd <- lapply(rmd, readLines)
# packs <- rm_between(rmd, c("library(", "require("), c(")", ")"), extract=TRUE)
# packs <- unique(unlist(packs))
# boot <- 'if (!require("pacman")) install.packages("pacman")'
# cat(paste0(boot, "\npacman::p_load(", paste(na.omit(unlist(packs)), collapse=", "), ")\n"))
source('r/runlearnr.R')
#rmarkdown::run("hello/hello.Rmd")
install.packages("pacman")
library(pacman)
pacman::p_load(tidyverse, openNLP, NLP, stringr, ggmap, WikidataR, ggplot2, psych, doBy, reshape2, knitr, lattice, learnr, dslabs, shiny, gradethis, textdata, wordcloud, ggwordcloud, wordcloud2, kableExtra, RSentiment, sentimentr, tidytext, corrplot, rsconnect, nycflights13, Lahman, qdapRegex)
```
## Data basics - week 4
Learn about how data works in `R`
```{r learnr_basics}
runlearnr("ex-data-basics/ex-data-basics.Rmd")
```
## Filtering and mutating data - week 4
Learn about how to do basic manipulation in `R`
```{r learnr_explor}
runlearnr("ex-data-filters/ex-data-filter.Rmd")
```
## Learn some basic summarisation and visualisation approaches
```{r}
runlearnr("ex-eda/eda.Rmd")
```
## MatchR
This one is more interesting! In this one, you will have to address _questions_ using outputs from `R`. You don't have to write any code yourself. Instead, you'll look at what the code outputs, and select the right code block to address the right question.
```{r learnr_matchr}
#You should have this directory locally, and so the first line will work. If you want to check you have the most current version, uncomment the github lines and run that.
if (interactive()) {
runlearnr("DSI-matchR/snippet_matchR_clustered_quizy.Rmd")
}
## to get from github
# if (interactive()) {
# shiny::runGitHub(repo = "learnr",
# username = "sjgknight",
# ref = "master",
# subdir = "DSI-matchR/")
# }
```
## Some more interactive tools to explore your data
You might find it useful to play with the expandar tool, which walks through some basic analysis functions (not all of which will be relevant for your data) and lets you export the bits you want.
The esquisse tool may also be a useful addon to use.
```{r exploratory}
pacman::p_load(ExPanDaR, esquisse)
ExPanDaR::ExPanD(mtcars)
esquisse::esquisser()
```
## CleanR
There are two resources you might like to explore here
Allison Horst's fantastic 'explore NA' interactive, which uses the `naniar` package to explore NAs in data, with a range of helpful visualisations (included with permission).
```{r learnr_na}
runlearnr("DSI-cleanR/explore-na-master/explore_na_tutorial.Rmd")
```
I've also started building an example of other common wrangling issues, it will include:
1. string cleaning (whitespace, strings that should be NA, etc.)
1. removing extraneous strings in numeric (Total: 873)
1. tidying variable types
1. reconciling names using both more manual dplyr approach, and refinr
1. converting currencies e.g. https://cran.r-project.org/web/packages/priceR/priceR.pdf
1. words-to-numbers
1. encoding-issue
... but it isn't finished yet. If you want to play with some of these issues, check the DSI-cleanR directory.
```{r learnr_cleanr}
```
## More!
If you like this style of tutorial, you might find some useful resources in:
1. http://milton-the-cat.rocks/home/adventr.html#Contents_of_adventr
1. https://github.com/RohanAlexander/DoSStoolkit the DoSStoolkit, in particular git_outta_here (to learn git), r_marky_markdown (to learn more markdown),
1. https://github.com/asteves/cinfeRence causal inference tutorials
1. https://ppbds.github.io/primer.tutorials/ bayesian statistics
If you're inspired and want to build some, or have ideas for useful tutorials or edits to the existing ones, please let me know!
You might also be interested in exploring https://psyteachr.github.io/webexercises/