# CUIRE

## R Objects Video

Screencasts about R Objects: Vectors, Matrices, Arrays, Lists and Dataframes

I’ve prepared some video tutorials to walk you through the material on this site. This page contains videos introducing R objects. The slides for this material can be found here.

Introduction to R Objects Part 1

This screencast defines 5 R objects: vectors, matrices, arrays, lists and data frames, and describes why they are important for epidemiologists.

Introduction to R Objects Part 2

A continuation of the description of R objects of interest to epidemiologists and the fucntions used to create them.

Basic Characteristics of R Objects

A description of what object modes and classes are, the difference between atomic and recursive objects, and how R can change or coerce data.

Numeric R Vectors

Numeric vectors are the basic building block of R data structures. How to create and index them.

Sorting R Vectors

The difference between sorting and ordering R vectors, and how to use the order() function to arrange one vector according to the levels of another vector.

Logical Vectors in R

Logical are created using conditional operators. They are the key to indexing, and indexing is the key to manipulating data in R. This screencast introduces how logical are created, and can be used to index other vectors.

R Matrices

This screencast introduces the R matrix, which is essentially a 2-dimensional vector, and forms the basis for tabular epidemiologic analyses in epidemiology. It shows how to create matrices with the matrix() function for summary data and with the table() function for individual-level data, as well as how to index arrays.

R Arrays

R arrays are n-dimensional vectors that correspond to stratified tables in epidemiologic analysis. This screencast shows how to create arrays with the array() function for summary data, and with the tables() and xtab() functions for individual-level data. It also introduces how to index arrays.

R Lists

A list can be made up of different kinds of R data types. Many functions return results as lists, and it is the basis for R data frames It can be created using the list() function.

`</iframe</code>><br /><br /><strong>R Data Frames</strong><br />An R data frame is the dataset format with which epidemiologists are most likely to be familiar, where rows represent individuals or observations and columns represent variables, which can be of different types. In R terms, it can be thought of as a list that behaves like a matrix.<br /><br /><code><iframe width="420" height="315" src="//www.youtube.com/embed/xc1wrvk1WB4" frameborder="0" allowfullscreen>`

Indexing R Data Frames 1

Data frames are flexible in how they can be indexed and manipulated. The three main approaches consist of indexing by position, by name and by logical vector.

Indexing R Data Frames 2

This screencast presents a short but non-trivial example of using logical indexing to manipulate an R data frame of hospital discharge data.

Reading Data into an R Data Frame

This screencast introduces the read.table() function and it's read.csv() convenience wrapper version as the most effective means of reading data into an R data frame.