gastonstat / stat33a

Introduction to Programming in R

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STAT 33A - Introduction to Programming in R

  • Description: This course introduces the R statistical software to students with minimal prior exposure to programming. The course aims to prepare students to carry out a basic data analysis and to write simple functions. The focus is on the computational model that underlies the R language with the goal of providing a foundation for further coding. Topics include (not necessarily covered in the following order):

    • Data types and data structures in R (e.g. vectors, arrays, lists, data frames)
    • Tools for data manipulation
    • Tools for data visualization
    • the REPL (read-evaluate-print loop) evaluation model
    • Control flow structures (e.g. conditionals, iterations)
    • Writing simple functions
    • Function calls
    • Argument matching
    • Data input/output
    • The formula language of R (time permitting)
  • Instructor: Gaston Sanchez

  • Lecture: 1 hour of lecture per week

  • Lab: 1 hour of laboratory per week

  • Assignments: biweekly HW assignments

  • Exams: one midterm exam, and final test

  • Texts and Notes:

  • LMS: the specific learning resources of a given semester are shared in the Learning Management Sysment (LMS) approved by Campus authorities (e.g. bCourses, Canvas)

  • Policies:


1. Introduction

πŸ“‡ ABOUT:

We begin with the usual review of the course policies, logistics, overall expectations, topics in a nutshell, etc. At the computational level, you'll get introduced to RStudio and R.


πŸ“– READING:


✏️ TOPICS:

  • Introduction
    • About the course
    • First contact with R and RStudio

2. Markdown

πŸ“‡ ABOUT:

You'll get introduced to Markdown and its use in dynamic computational documents (e.g. Rmd and qmd files).


πŸ“– READING:


✏️ TOPICS:

  • Markdown
    • Markdown syntax
    • R Markdown (Rmd) files

3. Data Types and Vectors

πŸ“‡ ABOUT:

In this week we describe data types and their implementation as vectors (the most fundamental data object in R).


πŸ“– READING:


✏️ TOPICS:

  • Data Types
    • atomic types (e.g. logical, integer, double, character)
    • coercion

4. More About Vectors

πŸ“‡ ABOUT:

We continue describing more aspects about vectors, specifically: 1) the notion of vectorized code, 2) the recycling principle, and 3) the so-called subsetting also known as subindexing or subscripting.


πŸ“– READING:


✏️ TOPICS:

  • About Vectors
    • Vectorization
    • Recycling principle
    • Subsetting

5. Other Atomic Objects

πŸ“‡ ABOUT:

We continue describing more atomic objects such as arrays (N-dimensional objects) and matrices (2-dimensional arrays).


πŸ“– READING:


✏️ TOPICS:

  • More atomic objects
    • Create simple matrices with matrix()
    • Describe and give examples of matrix subsetting (subscripting, indexing)
    • Explain in what sense a matrix is a 2-dimensional object

6. Non-atomic Objects

πŸ“‡ ABOUT:

In this week, we discuss lists, which are the most generic kind of data container in R.


πŸ“– READING:


✏️ TOPICS:

  • Lists
    • Manipulation of lists
    • Lists as one dimensional obejcts
    • Subsetting lists

7. Data Frames

πŸ“‡ ABOUT:

In this week, we discuss the basics of data frames, which are the dedicated object in R for handling tabular data sets.


πŸ“– READING:


✏️ TOPICS:

  • Data Frames
    • manipulation data frames (the "classic" way)
    • data frames as lists
    • data frames as two dimensional objects

8. Introduction to Functions

πŸ“‡ ABOUT:

You don’t need to be an expert programmer to use R, but learning more about programming allows you to automate common tasks, and solve new problems with greater ease. We'll discuss how to write basic functions, and the notion of R expressions.


πŸ“– READING:


✏️ TOPICS:

  • Functions
    • Main parts of a function (i.e. anatomy of a function)
    • Examples for creating a function
    • Concepts of an R compound expression

9. Conditional "if-else" statements

πŸ“‡ ABOUT:

If-else statements are one of the fundamental programming structures available in all programming languages. Simply put, an if-else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed.


πŸ“– READING:


✏️ TOPICS:

  • If-else statements
    • Anatomy of an if-else statement
    • Use of an if-else statements when writing functions to decide what code to execute

10. Iterations

πŸ“‡ ABOUT:

In addition to writing functions to reduce duplication in your code, you also need to learn about iteration, which helps you when you need to do the same operation several times. Namely, we review control flow structures such as for loops, while loops, repeat loops, and the apply family functions.


πŸ“– READING:


✏️ TOPICS:

  • Loops
    • Write for loops to repeat the same operation a given number of times
    • Write while loops to repeat the same operation an unknown number of time

11. Manipulation of strings

πŸ“‡ ABOUT:

Why should you learn about character string manipulation and working with text data? Well, because a considerable amount of information and data is precisely in the form of text. And sooner or later you will have to deal with some kind of string manipulation in most programming activities.


πŸ“– READING:

  • Slides

✏️ TOPICS:

  • Basic string processing
    • set of functions to perform basic manipulation of character strings.

12. Regular Expressions (part 1)

πŸ“‡ ABOUT:

A considerable amount of information and data is in the form of text. To unleash the power of string manipulation, you need to learn about Regular Expressions (or regex). Namely, regular expressions allow you to describe a certain amount of text called "patterns". We'll describe the basic concepts of regex and the common operations to match text patterns.


πŸ“– READING:

  • Slides

✏️ TOPICS:

  • Basic regex
    • literal characters
    • wildcard metacharacter
    • character sets

13. Regular Expressions (part 2)

πŸ“‡ ABOUT:

A considerable amount of information and data is in the form of text. To unleash the power of string manipulation, you need to learn about Regular Expressions (or regex). Namely, regular expressions allow you to describe a certain amount of text called "patterns". We'll describe the basic concepts of regex and the common operations to match text patterns.


πŸ“– READING:

  • Slides

✏️ TOPICS:

  • More regex
    • character ranges
    • posix classes
    • anchors
    • modifiers and quantifiers

About

Introduction to Programming in R