Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jrangel1802/R_Tutorials

 
 

Repository files navigation

R Programming Tutorials -- Winter 2017

Instructor: Professor Raya Feldman

Undergraduate Assistants:

  • Jason Freeberg, freeberg [at] umail.ucsb.edu
  • Aaron Nguyen, aaronknguyen [at] umail.ucsb.edu
  • Office Hours will be held on Sundays. Location and time will be announced on Gauchospace. We are also available by appointment during the week.

Lecture Time and Location: Wednesdays 7:00pm - 8:50pm, Girvetz 2128

Prerequisites: Students must be of upper division standing or recieve consent from the instructor. Students are are required to bring a laptop computer to lectures. Students should also have programming experience, either through UCSB classes or personal projects.

Grading: This class is offered for 1 unit, Pass/No Pass. Students will recieve a passing grade for attending and actively participating in 8 of the 9 lectures. (There is no lecture during Week 1, as we use that day to pass out add codes.)

  • During lecture on Week 7 (February 22nd) there will be a review examination. Scoring above 75% on this exam will allow a student to make up one (1) previous missed lecture attendance. This cannot be used towards future missed attendances after February 22nd.

Topics: This class will cover the basics of the R programming language and apply the material to real-world problems and data. In the first weeks, we will explore the fundamental objects and syntax of R. Next, we will learn how to load and format data. In the last weeks we will cover the basics of ggplot2, a popular data visualization package for R.

Textbooks and other resources: There are no required textbooks for this course. However, the following are all great resources for students learning the R language.

  • PSTAT's Piazza Group is where students can ask and answer R programming questions
  • Jupyter Notebook Docs has all the answers for installing, running, and saving Jupyter Notebooks
  • DataCamp.com is an interactive programming tutorial website and will be used for most homework assignments
  • The R Book is a great R reference manual
  • Google, for all your error messages and simple questions!

Software: Students are required to download following free programs/software and ensure they are running properly on their machine.

  • R, the programming language for the course
  • RStudio, the IDE for R
  • Jupyter, an interactive notebook we will use in every class
  • Video Walk-Through

Lesson Plan

Week 1, Jan. 11: Welcome

  • About this class
    • Students should have a programming background of some sort
    • Grading critera for the class
    • Homework for the quarter
  • Ensure all students are set up with course materials
    • R and RStudio
    • Jupyter
      • Along with the R kernel
    • DataCamp.com
  • Why R?
  • Cover the basics of running a Jupyter Notebook
  • Homework:
    • Install the course materials. See "Software" section above. Ensure they are functioning properly.

Week 2, Jan. 18: Basics of R -- Jason

  • R's data types
  • Vectors
    • Selection
    • Non-nesting
  • Writing clean code
    • Clean bad code for practice
  • Homework:

Week 3, Jan. 25: User-Defined Functions (UDFs) and Lists -- Aaron

  • Built-in Functions
    • Numerical / Statistical
    • Segway into students making the functions themselves.
  • UDFs
    • Make your code DRY
    • Divide and conquer
  • Exercise: Creating Your Own Functions
  • Lists
    • Generating
      • Named lists
    • Subsetting
  • Homework:
  • DataCamp: Introduction to R
    • Chapters 4 and 5: Factors and Dataframes
  • DataCamp: Intermediate R
    • Chapters 1 to 3: Contiditionals and Control Flow, Loops, and Functions

Week 4, Feb. 1: Data Frames -- Aaron

  • Conditioning and Subsetting
    • Syntax: dataframe[rows, columns]
  • New columns/rows
  • Exercise:
    • Create a clone of an existing data frame (or create your own if time permits)
    • Manipulate the data frame by adding new and old columns/rows
    • Sorting your data frame
  • Helpful functions
    • head(), summary(), glimpse(), is.na(), ...
  • Exercise:
    • Use these newly learned functions to find specific information in your data frame
  • Homework:

Week 5, Feb. 8th: Aggregating Data -- Jason

  • Using dplyr
    • Functions for basic analysis
    • Grouping data with group_by()
    • The piping operator, %>%
  • Joining dataframes
    • inner, outer, left, and right
  • Homework:

Week 6, Feb. 15th: Loading and Cleaning Data -- Jason

  • Formats
    • .csv and other delimited formats
    • JSON
  • Techniques for checking data
    • max and min values
    • unique factor levels
  • Regular Expressions
    • regex101.com
    • gsub()
  • Homework:
    • DataCamp: Cleaning Data in R
      • All exercises
    • Work through RegexOne.com's free online exercises.

Week 7, Feb. 22nd: Review Exam -- Jason and Aaron

  • Review Examination
    • Short Answer: Fill in the blank and multiple choice (8 questions)
    • Long Answer: Writing functions and correcting code (2 questions)
  • Tour of RStudio
    • Main components
    • Helpful tips
      • Console ^
      • Using the tab key
      • Organizing code with ####
  • Homework:
    • Complete all assigned Datacamp exercises up to this point.
    • DataCamp: Finish Intermediate R

Week 8, Mar. 1st: ggplot2 (Part I) -- Jason

  • Layering
    • Adding layers
  • Mapping
    • Basic aesthetics
  • Homework:

Week 9, Mar. 8th: ggplot2 (Part II) -- Jason

  • Deeper dive into ggplot2
    • Mapping multiple attributes
    • Static vs. Dynamic mapping
    • Layering generalized linear models
  • Homework:

Week 10, Mar. 15th: The Good and Bad of R -- Jason

  • R's strengths and weaknesses
    • Large memory footprint
    • Difficult to use in production
    • NULL columns
  • Compare R to other programming languages dominant in data science
    • Python using Pandas and matplotlib
  • Where to go now
    • Kaggle competitions
    • Personal projects
    • Shiny applications

About

PSTAT 193 course materials.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%