Simon A. Queenborough School of Forestry & Environmental Studies
Center for Teaching and Learning, Yale University | 2017-11-14 |
FES717 Tropical Field Ecology
old-school R
Motivation
Try something
Feedback (worked/didn’t work)
Try again (same/different)
Repetition
Assessment
Rapid feedback
Lecture -> Textbook -> Homework -> Exam
Slow
Little opportunity for expert feedback
Reading -> Mini Lecture -> Interactive Lesson -> Lab w Feedback
Followed rapid, short-cycle approach.
1920s ‘teaching machines’.
1950s B.F. Skinner “programmed instruction”.
1960s first generalised computer-assisted instruction system.
1980s adapted to computer programming (LISP, Pascal).
2000s internet, PCs: MOOCs, online tutorials, interactive textbooks, …
learn R outside of R.
each lesson was independent
web-based console or copy and pasting code from online resource
not open-source, so
unable to modify/contribute new material
Learn R, in R.
Continuous session, like real data analysis
Runs locally
100 percent open source
Anyone can author and share content
Integration with Coursera API/Google forms
Every new tech thing needs a nice acronym and logo
an R package for teaching and learning statistics and R simultaneously and interactively
Lessons are a dialogue between swirl and the user
Composed of:
Responses are evaluated for correctness based on instructor-specified answer tests.
Students work directly in R console = real working environment.
Allows immediate evaluation of code and immediate feedback.
Allows remote logging of scores so I can check progress and provide feedback.
You only need to do this once.
# install swirl.
# Requires ""
install.packages("swirl")
Lessons for FES720 are on my GitHub page
(github = social coding site, sharing code)
You only need to do this once (for now, until we find errors, etc)
# load the swirl pakcage
library(swirl)
# access github and download the course
# (this function is provided with the swirl package)
install_course_github("saq", "fes720_Basic")
This command downloads the first set of lessons to your computer.
You will need to do this every time you start R or want to continue an old lesson or start a new lesson.
# load the swirl package into your current R session
# (No need for "")
library(swirl)
| Hi! Type swirl() when you are ready to begin.
# start swirl ...
# (swirl is a function, so you need '()')
swirl()
> library(swirl)
| Welcome to swirl! Please sign in.
| If you've been here before, use the same name as you did then.
| If you are new, call yourself something unique.
What shall I call you?
Enter your name.
I will need to be able to identify you, so please use:
This name will also allow you to continue lessons if you stop them in the middle.
| Please choose a course, or type 0 to exit swirl.
1: fes720 Basic
2: Take me to the swirl course repository!
Selection:
We will be working through the lessons in the ‘fes720 Basic’ course.
Type: ‘1’
| Please choose a lesson, or type 0 to return to course menu.
1: Basic Building Blocks
2. ...
...
Choose the first lesson: Basic Building Blocks
Type: ‘1’
| Attempting to load lesson dependencies...
| Package ‘base64enc’ loaded correctly!
| | 0%
| In this lesson, we will explore some basic building blocks of the R programming language.
...
Hit ‘Enter’ to advance when presented with ‘…’
The screen also shows you how far through the lesson you are (0%).
You will need to be connected to the internet to submit your lesson
When you are done, the last question will ask if you want to submit your answers to me to verify that your completed the lesson.
You should enter the number of your response (usually ‘1’).
This will bring up a new web page, a Google form.
Scroll down, and click ‘submit’.
This will send an excrypted response to the Google form so that I can verify you completed the lesson.
Successful students will be able to:
. . .
. . .
The course will be assessed via:
A set of lesson assignments (25%, not assessed, but completion of all lessons is required),
A parallel set of lab problems (25%), submitted on Canvas.
Best Practice of the Week (25%), submitted on Canvas.
One (1) data project report (25%).
There are no final examinations.
Sat/Sun: Reading before class
Mondays: Background lecture on topic and lessons
Wednesdays: Best Practice lecture and labs
Fridays: R Bootcamp
Motivation
Repetition
Assessment
Rapid Feedback
all students come with data OR work on real data for NGO.
data project as part of course.
Lessons and labs build on each other sequentially, reinforcing skills.
Multiple similar tasks in lessons and labs, and on real data.
Two lessons a week (M, W), plus extended ‘R Bootcamp’ on Friday mornings.
BUT
only if the code does not run, not if it is not what was intended.
SWIRL automagically checks the answer!
SWIRL provides immediate feedback and hints for what we are looking for.
Expert help from me and TA:
In-class as students work on lessons and labs.
Labs: we make comments on Canvas asssignments several times a week. Multiple ‘submissions’ allowed.
Start them young
More time:
thinking,
planning,
interacting w students.
Less time:
Duplicating material (e.g., syllabus as hand-out + webpage, lecture as presentation + webpage, lesson as SWIRL + website/document).
Making things look pretty.
Single purpose applications
hides the working
hides the files and file structure
Open-source tools for plain-text coding, data analysis, and writing are also better and more accessible than they have ever been.
Based on work by Kieren Healy
e.g., M.S. Word file
changes tracked inside
citations and reference managers plug in
outputs of data analysis pasted in
e.g., plain-text file
changes tracked outside (version control)
data analysis managed in plain-text code
citations managed as plain-text
Final doc is assembled
Keep a Record
Write and Edit
Reproduce Work
Pull it Together
Record your actions (e.g., stats with code vs point and click)
Organize folders and files
Don’t Repeat Yourself
similar to MS Word track changes, but adds comments
Use for code, data, manuscripts
Allows you to ‘rewind’
Prevents: ‘paper-final.doc’, ‘paper-final2.doc’, ‘paper-really-final.doc’, ..
e.g., git, subversion, ..
e.g., Github
e.g., Dropbox, YaleBox, …
Focus on content, appearance (typesetting) done elsewhere
Portable, open by anything
Highlighting (helps w code syntax, but can also error-check)
Possible to integrate text and code
e.g., too many! Notepad+, …
Now, a standard mark-up language
Simple format for structural info + easy to read
# 2. Write and Edit
## Use Markdown
- Now, a standard _mark-up_ language
- Simple format for structural info + easy to read
Syntax highlighting
Error-checking
Avoid errors creping in
Work out what you did 6 months ago!
Comment code and make it readable
Blah, blah, as you see in Fig. 1 blah ...
```r
# Embed chunks of code
my_data <- read.table('my_awesome_data.txt')
plot(my_data$x ~ my_data$y)
Now, turning to blah ...
http://wcm1.web.rice.edu/plain-text-citations.html
http://mnmlist.com/a-case-for-storing-all-your-info-in-text-files/
http://kieranhealy.org/blog/archives/2014/01/23/plain-text/
http://programminghistorian.org/lessons/sustainable-authorship-in-plain-text-using-pandoc-and-markdown
http://inundata.org/2012/12/04/how-to-ditch-word/
http://inundata.org/2012/06/01/markdown-and-the-future-of-collaborative-manuscript-writing/
http://wcm1.web.rice.edu/plain-text-citations.html
http://mnmlist.com/a-case-for-storing-all-your-info-in-text-files/
http://kieranhealy.org/blog/archives/2014/01/23/plain-text/
http://programminghistorian.org/lessons/sustainable-authorship-in-plain-text-using-pandoc-and-markdown
http://lifehacker.com/5943320/what-is-markdown-and-why-is-it-better-for-my-to+do-lists-and-notes
http://chronicle.com/blogs/profhacker/markdown-the-syntax-you-probably-already-know/35295
http://www.practicallyefficient.com/2011/07/21/word-internet/
http://markdowntutorial.com/
https://daringfireball.net/projects/markdown/basics
http://conjugateprior.org/2013/03/tools-for-making-a-paper/
http://hybridpedagogy.com/Journal/files/GitHub_for_Academics.html
https://github.com/SChamberlain/esamd
======
R A platform for statistical computing.
RStudio IDE for R.
knitr Reproducible documents with R.
LaTeX Detailed mark-up language and typesetting system.
pandoc Converts plain-text to many other formats.
git Version control system.
github Social web-based version of git.
Intro to R My course!