Mine Dogucu
Assistant Professor of Teaching
Department of Statistics
M 10 - 11 am, F 3 - 4 pm
mdogucu@uci.edu
MineDogucu
mdogucu
Introduction to the Course
Introduction to R and RStudio
Introduction to R Markdown
Introduction to Git and GitHub
Introduction the Course
By the end of this program you should be able to adopt reproducible computing workflows.
By the end of this program you should be able to adopt reproducible computing workflows in R.
By the end of this course you should be able to adopt reproducible computing workflows in R for all your scientific work (e.g. data management, analysis, dissemination).
By the end of this course you should be able to adopt reproducible computing workflows in R for all your scientific work (e.g. data management, analysis, dissemination).
I may not teach you every single detail on the topic but you will gain enough foundations to tailor it to your future work.
Introduction to R
R review
birth_year <- 1950
birth_year <- 1950
Windows | Mac | |
---|---|---|
Shortcut | Alt + - | Option + - |
my_age <- 2020 - birth_yearMy_age
Error in eval(expr, envir, enclos): object 'My_age' not found
my_age <- 2020 - birth_yearMy_age
Error in eval(expr, envir, enclos): object 'My_age' not found
If something comes in quotes, it is not defined in R.
ages <- c(25, my_age, 32)names <- c("Menglin", "Mine", "Rafael")data.frame(age = ages, name = names)
age name1 25 Menglin2 70 Mine3 32 Rafael
do(something)
do()
is a function;something
is the argument of the function.
do(something)
do()
is a function;something
is the argument of the function.
do(something, colorful)
do()
is a function;something
is the first argument of the function;colorful
is the second argument of the function.
In order to get any help we can use ?
followed by function (or object) name.
?c
canyoureadthissentence?
canyoureadthissentence?
age <- c(6, 9, 15)data.frame(age_kid = age)
canyoureadthissentence?
age <- c(6, 9, 15)data.frame(age_kid = age)
After function names do not leave any spaces.
Before and after operators (e.g. <-, =) leave spaces.
Put a space after a comma, not before.
Object names are all lower case, with words separated by an underscore.
Introduction to R Markdown
markup languages
$\frac{3}{5}$
\(\frac{3}{5}\)
<a href = "http://minedogucu.com"> Mine Dogucu</a>
R Markdown
R Markdown
_Hello world_ __Hello world__~~Hello world~~
Hello world
Hello world
Hello world
= .R file
= .md file
+ = .Rmd file
output:pdf_document
output:pdf_document
output: html_document: toc: true
output:pdf_document
output: html_document: toc: true
output: html_document: fig_width: 7 fig_height: 6
More in the R Markdown book
File > New File > R Markdown
Windows | Mac | |
---|---|---|
add chunk | Ctrl + Alt + I | Cmd + Option + I |
run the current chunk | Ctrl + Alt + C | Cmd + Option + C |
run current line/selection | Ctrl + Enter | Cmd + Return |
knit | Ctrl + Shift + K | Cmd + Shift + K |
echo = FALSE | hides the code |
message = FALSE | hides messages |
warning = FALSE | hides warning |
error = TRUE | renders despite errors and displays the error |
eval = FALSE | code is not evaluated |
cache = TRUE | will not run if it has been run before and the output from previous run would be used |
Slides that you are currently looking at are also written in R Markdown. You can take a look at them on GitHub repo for the course website. They are made with xaringan package which we will talk more about later.
Introduction to Git and GitHub
Who uses GitHub?
Who uses GitHub?
hw1
hw1
hw1_final
hw1
hw1_final
hw1_final2
hw1
hw1_final
hw1_final2
hw1_final3
hw1
hw1_final
hw1_final2
hw1_final3
hw1_finalwithfinalimages
hw1
hw1_final
hw1_final2
hw1_final3
hw1_finalwithfinalimages
hw1_finalestfinal
What if we tracked our file with a better names for each version?
What if we tracked our file with a better names for each version?
hw1 added name
What if we tracked our file with a better names for each version?
hw1 added name
hw1 added question 1 image
What if we tracked our file with a better names for each version?
hw1 added name
hw1 added question 1 image
hw1 changed name/ added group mate
What if we tracked our file with a better names for each version?
hw1 added name
hw1 added question 1 image
hw1 changed name/ added group mate
hw1 added first draft of all questions
What if we tracked our file with a better names for each version?
hw1 added name
hw1 added question 1 image
hw1 changed name/ added group mate
hw1 added first draft of all questions
We will call the descriptions in bold commit messages.
Commit often but not too often. If in doubt, commit often.
repo is a short form of repository. Repositories contain all of your project's files as well as each file's revision history.
For this class our weekly repos (lecture code, quiz code etc.) are hosted on Github.
To clone a GitHub repo to our computer, we first copy the cloning link as shown in screencast then start an RStudio project using that link.
Cloning a repo pulls (downloads) all the elements of a repo available at that specific time.
Once you make changes to your repo (e.g. take notes during lecture, answer a quiz question). you can take a snapshot of your changes with a commit.
This way if you ever have to go back in version history you have your older commits to get back to. This is especially useful, for instance, if you want to go back to an earlier solution you have committed.
All the commits you make will initially be local (i.e. on your own computer).
In order for me to see your commits and your final submission on any assignment, you have to push your commits. In other words upload your files at the stage in that specific time.
Git: is software for tracking changes in any set of files
GitHub: is an internet host for Git projects.
repo: is a short form of repository. Repositories contain all of your project's files as well as each file's revision history.
clone: Cloning a repo pulls (downloads) all the elements of a repo available at that specific time.
commit: A snapshot of your repo at a specific point in time. We distinguish each commit with a commit message.
push: Uploads the latest "committed" state of your repo to GitHub.
git it?
Mine Dogucu
Assistant Professor of Teaching
Department of Statistics
M 10 - 11 am, F 3 - 4 pm
mdogucu@uci.edu
MineDogucu
mdogucu
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |