Contents
Data Structures and Control Flow
Vectors, Matrices, and Arrays
A vector is a list of values of the same type. A matrix is a table with rows and columns where all values share one type. An array is like a matrix with more than two dimensions.
Vectors are the most important structure because every column in a table is a vector.

Lists, Factors, and Data Frames
A list can hold different types of items together. A factor stores categories, such as low and high. A data frame is a table where each column is a vector and each row is one record.
A data frame is the structure you will use most in data science because it looks just like a spreadsheet.

Conditional Statements and Loops
A conditional lets your code make decisions with if and else. A loop repeats an action. The for loop repeats once for each item in a set.
Keep the code inside curly brackets neatly lined up so it is easy to read.
Use loops to learn the idea. Later, you will see that vectorized functions such as ifelse() are shorter and faster for whole columns.

R for Data Science
Harini A








