Module 1 Flashcards
When to use R
raw data is complex
R & RStudio are designed to handle large data sets and can easily reproduce work on different data sets.
Flexible data visualisation - difference across cities effectively using plotting features like facets.
Automaticallt create output of summary stats - or visualised plots for each group.
Fundamentals using programming in R-studio
Coding in RStudio
Syntax for performing calculations
Pipes
R packages
Basic concepts of R
Functions
Comments
Variables
Data Types
Vectors
Pipes
Functions (R)
A body of reusable code used to perform specific tasks in R
Argument (R)
Information that a function in R needs in order to run
Variable (R)
A representation of a value in R that can be stored for use later during the programming
Vector (R)
Group of data elements of the same type stored in a sequence in R c(X, Y, Z)
Pipe (R)
A tool in R for expressing a sequence of multiple operations, represented with “%>%”
Data Structure
format for organising and storing data (Vectors/Data frames/Matrice/Arrays)
2 different types of vectors in r
atomic and lists
6 different types of atomic vectors
logical, integer, double, character (which contains strings), complex, and raw.
How can you determine the properties of vectors
typeof() function
naming vectors
names() fucntion can be used to name elements of a vector
x <- c(“a”, “b”, “c”)
atomic vectors
c(x, y, z)..
can only be made with variables of the same type.
homogenous
how do you determine the structure of lists
str(list, x, y, z..)
What type of vectors are numeric
Integar and double vectors
Lists
heterogeneous
Logical Vectors
simplest type of atomic vector and can only contain 3 values, TRUE, FALSE, NA
Three ways to likely creat date-time formats
From a string
From an individual date
From an exisiting date/time
Data Frame
A collection of columns containing data, similar to a spreadsheet or SQL table.
Data frames summarise data and organise it into a format that is easy to read and use.
data.frame
Characteristics of Data Frames
variety of data types
only one element in each cell
columns should be names
each column consists of elements of the same data tyoe
Extract Operator Data Frames
two arguments
1. the row(s)
2.column(s) you like to extract
e.g. x[2,1]
will draw the second row and first column of the data frame assigned to x
Create a file
create.file - if TRUE response in the console than the file has been created. If FALSE, then file has not been created
Copy a file
file.copy