+ - 0:00:00
Notes for current slide
Notes for next slide



Introduction to the Toolkit

Dr. Mine Dogucu

1 / 78

A headshot of a woman with curly, short, ear-length hair with green eyes and red lipstick.

Mine Dogucu
Assistant Professor of Teaching
Department of Statistics

M 10 - 11 am, F 3 - 4 pm
mdogucu@uci.edu
MineDogucu
mdogucu

2 / 78

A headshot of a woman with long straight hair and glasses

Josie Jiang
PhD Student
Department of Statistics

xiwenj@uci.edu
XiwenJiang

3 / 78

Goals

  • Introduction to the Course

  • Introduction to R and RStudio

  • Introduction to R Markdown

  • Introduction to Git and GitHub

4 / 78

Introduction the Course

5 / 78

By the end of this program you should be able to adopt reproducible computing workflows.

6 / 78

By the end of this program you should be able to adopt reproducible computing workflows in R.

7 / 78

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).

8 / 78

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.

9 / 78

End Products

  • Personal website (will come as homework)
  • R package
  • Final project of your own choice
10 / 78

Introduction to R

11 / 78
12 / 78

R review

13 / 78

Object assignment operator

birth_year <- 1950
14 / 78

Object assignment operator

birth_year <- 1950
Windows Mac
Shortcut Alt + - Option + -
15 / 78

R is case-sensitive

my_age <- 2020 - birth_year
My_age
Error in eval(expr, envir, enclos): object 'My_age' not found
16 / 78

R is case-sensitive

my_age <- 2020 - birth_year
My_age
Error in eval(expr, envir, enclos): object 'My_age' not found
17 / 78

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 name
1 25 Menglin
2 70 Mine
3 32 Rafael
18 / 78

Vocabulary

do(something)

do() is a function;
something is the argument of the function.

19 / 78

Vocabulary

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.

20 / 78

Getting Help

In order to get any help we can use ? followed by function (or object) name.

?c
21 / 78

tidyverse_style_guide

canyoureadthissentence?

22 / 78

tidyverse_style_guide

canyoureadthissentence?

age <- c(6, 9, 15)
data.frame(age_kid = age)
23 / 78

tidyverse_style_guide

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.

The tidyverse style guide

24 / 78

RStudio Setup

25 / 78

Introduction to R Markdown

26 / 78

markup languages

27 / 78

LaTeX


$\frac{3}{5}$

\(\frac{3}{5}\)

28 / 78

HTML (Hypertext Markup Language)


<a href = "http://minedogucu.com">
Mine Dogucu</a>
29 / 78

markdown


[Mine Dogucu](http://minedogucu.com)
30 / 78

R Markdown

31 / 78

R Markdown

32 / 78

markdown


_Hello world_
__Hello world__
~~Hello world~~

Hello world

Hello world

Hello world

33 / 78

= .R file

= .md file

+ = .Rmd file

34 / 78

markdown document

35 / 78

R Markdown document

36 / 78

YAML (Yet Another Markup Language)

37 / 78

More YAML

output:pdf_document
38 / 78

More YAML

output:pdf_document
output:
html_document:
toc: true
39 / 78

More YAML

output:pdf_document
output:
html_document:
toc: true
output:
html_document:
fig_width: 7
fig_height: 6

More in the R Markdown book

40 / 78

Parameterized Reporting in R Markdown

41 / 78

42 / 78

Starting a New R Markdown document

File > New File > R Markdown

43 / 78

Add Chunk

44 / 78

Run the Current Chunk

45 / 78

Knit

46 / 78

Shortcuts

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
47 / 78

(some) Chunk Options

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
48 / 78

Slides

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.

49 / 78

Introduction to Git and GitHub

50 / 78

51 / 78

Who uses GitHub?

52 / 78

Who uses GitHub?

53 / 78

Version control

hw1

54 / 78

Version control

hw1

hw1_final

55 / 78

Version control

hw1

hw1_final

hw1_final2

56 / 78

Version control

hw1

hw1_final

hw1_final2

hw1_final3

57 / 78

Version control

hw1

hw1_final

hw1_final2

hw1_final3

hw1_finalwithfinalimages

58 / 78

Version control

hw1

hw1_final

hw1_final2

hw1_final3

hw1_finalwithfinalimages

hw1_finalestfinal

59 / 78

What if we tracked our file with a better names for each version?

60 / 78

What if we tracked our file with a better names for each version?

hw1 added name

61 / 78

What if we tracked our file with a better names for each version?

hw1 added name

hw1 added question 1 image

62 / 78

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

63 / 78

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

64 / 78

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.

65 / 78

66 / 78

67 / 78

68 / 78

69 / 78

70 / 78

71 / 78

Art of commit messages that is learned with practice

Commit often but not too often. If in doubt, commit often.

72 / 78
73 / 78

Cloning a repo

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.

74 / 78

Commits

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.

75 / 78

Push

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.

76 / 78

(An incomplete) Git/GitHub glossary

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.

77 / 78

git it?

78 / 78

A headshot of a woman with curly, short, ear-length hair with green eyes and red lipstick.

Mine Dogucu
Assistant Professor of Teaching
Department of Statistics

M 10 - 11 am, F 3 - 4 pm
mdogucu@uci.edu
MineDogucu
mdogucu

2 / 78
Paused

Help

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