Lecture 3

Installing the DANL Tools

Byeong-Hak Choe

SUNY Geneseo

January 30, 2024

Announcement

  • Office Hours
    1. Tuesdays 12:30 P.M.—1:30 P.M.
    2. Wednesdays 12:30 P.M.—2:30 P.M.
  • DANL tutoring sessions will be announced soon.

Announcement

GitHub Notifications Setting

  • If you want to avoid a ton of notification emails,
    1. Go to https://github.com, and log in.
    2. Click the mailbox icon at the top right corner next to the profile icon.
    3. Click “Manage notifications” at the bottom of the side bar.
    4. Click “Notification settings”.
    5. Scroll down to the “Subscriptions” menu.
    6. Click “Notify me on …” from the “Watching” sub-menu, uncheck “Email”, and save it.
    7. Click “Notify me on …” from the “Participating, …” sub-menu, uncheck “Email”, and save it.

Learning Objectives

  • Set up the DANL tools in your laptop.

    • R/RStudio if you have not
    • R Package tidyverse if you have not
  • Build your personal website

  • Practice Markdown (if we have time)

RStudio and tidyverse

RStudio

Script Pane

  • Script Pane is where you write an R script or a Quarto document that you can save.
  • An R script is simply a text file containing R commands.
  • To open an R script,
    • File \(>\) New File \(>\) R Script
  • To save the R script,
    • File \(>\) Save

RStudio

Console Pane

  • Console Pane allows you to interact directly with the R interpreter and type commands where R will immediately execute them.
    • In R Console, we use R commands.
  • From Terminal in the Console Pane, we can use git commands.

RStudio

Environment Pane

  • Environment Pane is where you can see the values of variables, data frames, and other objects that are currently stored in memory.

  • Type below in the Console Pane, and then hit Enter:

a <- 1

RStudio

Plots Pane

  • Plots Pane contains any graphics that you generate from your R code.

RStudio Workflow

Shortcuts for RStudio and RScript

Mac

  • command + shift + N opens a new RScript.
  • command + return runs a current line or selected lines.
  • command + shift + C is the shortcut for # (commenting).
  • option + - is the shortcut for <-.

Windows

  • Ctrl + Shift + N opens a new RS-cript.
  • Ctrl + return runs a current line or selected lines.
  • Ctrl + Shift + C is the shortcut for # (commenting).
  • Alt + - is the shortcut for <-.

Computer Basics

tidyverse Package

  • The tidyverse is a collection of R packages designed for data science that share an underlying design philosophy, grammar, and data structures.
  • tidyverse includes a lot of R packages, including ggplot2, dplyr, and tidyr.

  • The tidyverse packages work harmoniously together to make data manipulation, exploration, and visualization more.

Installing the Tools

Loading R packages with library(packageName)

  • Once installed, a package is loaded into an R session using a base-R function library(packageName) so that R package’s functions and data can be used.
    • To load the R package tidyverse, type and run the following commands from a R script:
library(tidyverse)
df_mpg <- mpg
  • mpg is the data.frame provided by the R package ggplot2, one of the R pakcages in tidyverse.
    • Since tidyverse is installed, ggplot2 package is already installed.
  • Seeing the message—Error in library(tidyverse) : there is no package called ‘tidyverse’—when running library(tidyverse) indicates that tidyverse is not installed.

Installing the Tools

Installing R packages with install.packages("packageName")

  • If tidyverse is not installed, copy and paste the following commands to the R script. Then run the commands.
update.packages(ask = FALSE, checkBuilt = TRUE)
install.packages( "tidyverse", 
  dependencies = c("Depends", "Imports", "LinkingTo") )
  • While running the above codes, you may encounter the question below from the R Console:
  • Mac: “Do you want to install from sources the packages which need compilation?” from Console Pane.
  • Windows: “Would you like to use a personal library instead?” from pop-up message.
  • Type no in the R Console, and then hit Enter.

Installing the Tools

RStudio Options Setting

  • This option menu is found by menus as follows:
    • Tools \(>\) Global Options
  • Check the boxes as in the left.
  • Choose the option Never for Save workspace to .RData on exit:

Installing the Tools

Installing the Tools

Building a Website

Installing the Tools

Practice Markdown

  • Quarto and GitHub-based Discussion Boards use markdown as its underlying document syntax.

  • Let’s do Classwork 3.