-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
82 lines (63 loc) · 2.98 KB
/
README.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
---
title: decs922 R package
output: github_document
---
This is a package of odds and ends originally created for the class
Data Exploration, DECS-922, now DECS-461, at the [Kellogg School of
Management](https://www.kellogg.northwestern.edu/).
```{r, echo=FALSE}
library(decs922)
```
# Document production
* Templates to perform routine setup steps to produce beamer slides
and pdf homework assignments. Upon package installation these
become automatically available from RStudio's `rmarkdown` templates
list, as templates named "`decs922 Beamer presentation`" and "`decs922
homework submissions`".
Note that the `decs922 homework
submission ` template contains a mini-tutorial concerning
aspects of producing a document with markdown, including
examples of cross-referencing of tables and figures.
* A `knitr` chunk engine, `soln_notes`, which allows you to insert
optional text within a standalone chunk with the engine
`soln_notes`. When evaluated, the text will be rendered in italic
and (by default) preceded by `Solution notes:`. The goal is to make
it easier to create homework solutions. The implementation is
currently functional but buggy.
* **`nbsp`** which takes a string as input and returns the
string with spaces replaced by non-breaking spaces.
# Utility functions
* **`translate_datestr`** parses a string for POSIX
date codes and returns documentation for the codes (taken from `?strftime`).
```{r}
translate_datestr('%Y-%M-%d')
```
* **`data_summary`** reports for a data set the number
of observations, number of missing values, the class of each
variable, and various summary statistics. I view this as
pedagogical, as there are *many* similar functions available, such
as `summary`, `psych::describe`, etc. Using the
built-in dataset `iris`:
```{r}
data_summary(iris)
```
* **`wordle_assist`** finds 5-letter words that match against excluded letters and positional
included letters (a vector named with the letter, with positive values
specifying confirmed positions and negative values specifying
positional exclusions). The function matches against
the length-5 words in the [`words` package](https://CRAN.R-project.org/package=words). For example, suppose you have played `arose`, `until` and `chump`, and you've learned that there is an `s` in position 1 but not in position 4; there is an `h` in position 2; and there is an `o` in position 3. Enter that information like this:
```{r}
wordle_assist(no = 'areuntilcump', yes = list(s = c(1, -4), h = 2, o = 3))
```
The function returns the remaining possible words.
* **`wordle_sub`** given 1 to 5 letters, return 5-letter words containing
those letters, in any order.
```{r}
wordle_sub(ltrs='cawk')
```
* **`colorkey`** given a regex, returns matching values from
`colors()`. For example, to find a version of "orange" which does
not contain "red" in the color name:
```{r, out.width='70%'}
colorkey(colortext = 'orange', excludetext = 'red')
```