Programming in R
So far we have relied on the built-in functionality of R to
carry out our analyses. In the next several lectures, well
Importing packages into R
How to write your own functions
The meaning of environments and variable scope
How to u
February 8, 2016
In this activity, youre going to examine how the number of daily births in the US varies over the years.
Births each day
The data table Birthdays in the mosaicData package gives the number of births recorded on
Statistics 133 -Writing Functions in R
1. Write a function that takes a number year and returns a logical value which is either
TRUE, if the year was or will be a leap year, or FALSE if not. The rule for determining
leap years is that one of the following
Graphics in R
Part 1: High-level graphics
Well be working in this section with many of Rs built-in
data sets. To see a list of them, just type
Data sets in package 'datasets':
Statistics 133: Concepts in
Computing with Data
Instructor: Dr. Cari Kaufman
GSIs: Fu Shi, Katia Eliseeva
What Are Data?
Example: Trafc on I-80
Dates, Times, Locations
Dates, Times, Locations
Example: Trafc fatalities (
There are a few more concepts we need to manipulate
text data and use regular expressions in R:
1. Getting text data into R
2. Greedy matching
3. Tagging and back references
Well cover these in the context of learning how to
Before we consider the role that simulation can play in
helping us understand statistics, lets take a step back and
think about the big picture.
We can think of probability theory as complimentary to
Regular expressions give us a powerful way of matching
patterns in text data.
Example 1: election data from three different datasets.
We know these are the same places, but how can the
computer recognize that?
Example 2: Creating v
We will use the RDBMS called PostgreSQL:
Postgres has its own internal commands that arent SQL
commands. Some useful ones are
- see all tables
\d tablename - describe a particular table
- display history (commands
Databases and SQL
A database is a collection of data with information about
how the data are organized (meta-data). A database server
is like a web server, but responds to requests for data
rather than web pages.
Well talk about how to communicate with
Advanced Graphics in R:
Through packages, the R graphics system may be
extended in a number of powerful ways. The Graphics
taskview at CRAN documents the available packages.
Today well focus on
- ne control of color
- making 3D scatterplots and
Most of the data sets weve seen have been in the form of
An operating system (OS) is a piece of software that
controls the hardware and other pieces of software on
The most popular OS today, Microsoft Windows, uses a
graphical user interface (GUI) for you to interact
A Graph for the Economist
February 17, 2016
The Economist is a well-regarded weekly news magazine. The following graphic accompanied their article
about the release of the College Scorecard data in Sept. 2015.