WEEK 2: Programming and using RStudio Flashcards
Functions
begin with function names like print or paste, and are usually followed by one or more arguments in parentheses.
An argument
Is information that a function in R needs in order to run.
If you want to find out more about any function
All you have to do is type a question mark, the function name, and a set of parentheses.
A variable
Is a representation of a value in R that can be stored for use later during programming.
A variable name should start with a letter and can also contain numbers and underscores.
The name of the variable <- the value of variable
Ex: City <- 12 or “Mony”
Comments
Are helpful when you want to describe or explain what’s going on in your code.
Comments should be used to make an R script more readable.
How to comment in R: #text
A vector
Is a group of data elements of the same type stored in a sequence in R.
Vec <- c(x,y,z,…)
A pipe
Is a tool in R for expressing a sequence of multiple operations.
%>%
A data frame
Is a collection of columns–similar to a spreadsheet or SQL table.
A matrix
Is a two-dimensional collection of data elements. This means it has both rows and columns.
Packages in R include
Reusable R functions
Documentation about the functions, including how to use them.
Sample datasets
Tests for checking your code to make sure it does what you want it to do.
Conflicts happen when
Packages have functions with the same names as other functions.
Tydiverse packages
Ggplot2 is used for data visualization, specifically plots.
Tidyr is a package used for data cleaning to make tidy data.
Readr is used for importing data.
Dplyr offers a consistent set of functions that help you complete some common data manipulation tasks.
Factors
Store categorical data in R where the data values are limited and usually based on a finite group like country or year.