-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.Rmd
94 lines (68 loc) · 7.17 KB
/
index.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
---
title: "teacheR"
subtitle: "Teach Yourself or Others R"
author: "Adam Rawles"
always_allow_html: true
site: bookdown::bookdown_site
output:
bookdown::gitbook:
config:
toc:
collapse: subsection
download:
- ["teacheR.pdf", "PDF"]
- ["teacheR.mobi", "Kindle EBook"]
- ["teacheR.epub", "EPUB EBook"]
bookdown::pdf_book:
extra_dependencies: ["float"]
includes:
in_header: template.tex
bookdown::epub_book:
cover_image: "cover.png"
documentclass: book
favicon: "favicon.ico"
cover-image: "cover.png"
description: "Teach yourself or others R with this introduction to the fundamentals of the R language."
github-repo: ARawles/teacheR
links-as-notes: true
---
```{r include = FALSE}
if(!knitr:::is_html_output())
{
options("width"=56)
knitr::opts_chunk$set(tidy.opts=list(width.cutoff=56, indent = 2), tidy = TRUE)
knitr::opts_chunk$set(fig.pos = 'H')
}
```
# teacheR (1^st^ Edition)
<img src="cover.png" width="250" height="375" alt="Cover image" align="right" style="margin: 0 1em 0 1em" />
## Overview
This book is a collection of training materials for an introduction to the R statistical computing programming language. Broken down into chapters, I've aimed to cover most of the basics.
The book is largely split into two sections. One section ("For Students") that's aimed at those that are entirely new to R. I explain the basics in a way that doesn't require a background in data analysis or computing and you should have a decent understanding of the fundamentals of R if you manage to make it through.
In the second section ("For Teachers"), we look at some of the topics in greater detail, looking at the theory and specifics that underpin what we've learnt in the previous section. For those interested in teaching R to others, this section provides an introduction to the underlying workings of R that can be extremely helpful when questions from your students begin to arise. For example, we look at functions in both sections, however we cover the basics of what a function is and how to use one in the "For Students" section, and how to create functions in the "For Teachers" section.
I'm constantly looking to improve this book so feedback is very welcome. Anything from typos to content suggestions, feel free to raise a [GitHub issue](https://github.com/arawles/teacher/issues) if you feel something should be changed.
### Acknowledgements
This book was made possible with the help of those who raised issues and proposed pull requests. With thanks to:
```{r, results = "asis", echo = FALSE, message = FALSE}
library(dplyr)
contributors <- read.csv("contribs.csv", stringsAsFactors = FALSE)
contributors <- contributors %>%
mutate(
link = glue::glue("[\\@{login}](https://github.com/{login})"),
desc = ifelse(is.na(name), link, glue::glue("{name} ({link})"))
)
cat(paste0(contributors$desc, collapse = ", "))
```
## About Me
I began using R in my second year of university, during an internship looking at publication bias correction methods. I was under the tutorship of a member of staff who helped me immensely, but I must confess that I have never taken an official course in R, online or in person. I like to think, however, that this is not always a bad thing. Learning from the bottom up and struggling along the way is a fantastic way to acquire knowledge and instills a very important lesson:
**You're not going to know everything there is to know about R. Ever. But that's okay.**
I'm now 4 years into my R career and I use R every day. With that in mind, I don't think there has ever been a day when I haven't referred to a tutorial, or Stack Overflow, or even just Googled the name of a function that I've used 1000 times before. There is a great repository of knowledge for R and it's one of the things I love most about the R community. So please never feel as though you're an impostor in a world of R gurus. In reality, everyone else is just as lost as you. But if you keep ticking along and never feel that learning something new in R isn't worth your time, you'll end up doing some great things.
And in a roundabout way, that is part of the reason I decided to develop these materials. I don't pretend to be the ultimate R programmer, because I still know what it's like to learn something from the start. And everyone has to start somewhere. So I hope that I can help impart some of the lessons that I've learnt over the 4 years to anyone who's looking to learn R in a way that won't leave you feeling lost.
The only final note I have before we start learning how to use R is another bit of advice:
**Make bad things before you make good things**.
By this, I mean that not everything you do will be a work of art and that's okay. Perfectionism is the enemy of progress and often the best way to write code is write something bad at first and then improve it bit by bit. When I look back to code that I wrote when I first started R, it's a symphony of repitition, a lack of abstraction and terrible variable names. And as bad as it hurts my eyes when I look back at it, I love it. Because it's a signal that I didn't let embarassment or imposter syndrome get the better of me - I tried my best and got stuck in and now I can look back and know I've improved my R skills. So don't be scared or embarassed when you code - write bad things, look for improvements and advice and make it better.
## Why teacheR?
Most books are written as though you are a student. They teach you things so that you can pass a test or do whatever it was you need to do to move onto the next level or finish your project. This is very useful when you have a very specific goal in mind. For instance, people often get into R because they have a particular project they want to work on or because they think it could be useful for their work. Reading a book tailored to that type of project or work can therefore be very useful.
However, learning R this way, or learning anything for that matter, can present with some problems later down the line. Primarily, you've just learnt to do something very specific. There will certainly be tips and skills that will be transferable to future projects, but even then, once you've got a hammer, everything can start looking very nail-like.
And so I often try and take a different approach when learning and teaching R. **Imagine that you're learning R not as a means to an end, but because you're going to teach it to someone else**. This forces a more balanced and universal understanding, and can really help with your knowledge retention. When I began teaching R, my knowledge of R and how it works grew much faster than it ever had. And it was because of the teaching; people will ask insightful questions, ask you what happens when you do this or that and why does that happen, and those questions will force you to better understand R and how it works. It's perfectly okay to say that you don't know the answer when teaching, but when someone asks you why `"TRUE"` is apparently the same as `TRUE` but `"True"` isn't the same as `TRUE`, I defy anyone who's not curious enough to look it up afterwards.
So when you read this book, don't think of yourself as a lowly student who's learning R to pass their A Levels. Instead, think of yourself as a teacher in training.