RStudio functions: Flashcards
A + B + Enter button
Answer for A + B
*
Multiply
/
Divide
To the power of
Brackets
To separate different functions used in one
A ← 3
Store the value 3 in variable A
What is a scalar variable?
A variable storing a single value
Variable (eg. A) + Enter
Displays value stored in variable
C ← “apples”
Stores the word apples in variable C
What are vectors?
Variables that can hold more than one value
D ← c(3, 7, 1)
Stores vector 3, 7, 1 in variable D
C stands for combine
D[2]
Allows access to the second value stored in the vector variable D
What are data frames?
A store of large amounts of data
Putting name of data frame
Displays the full set of data in data frame
Cars$Mpg
Codes for only mpg column in the cars data frame
DateFrameName[RowNumber, ColumnNumber]
Helps distinguish between rows and columns in a table
Cars[ , 1]
When row number is left blank, it will return all the rows.
In this example, the first column of rows of car will be returned
What is a function?
Anything that performs a particular operation on our data
What is the format that all functions follow on R Studio?
Function_name(argument)
What is an argument?
The input for the function
What would the function “ mean(e) “ do?
Give the mean/average of values in vector e
What code would you use to calculate the mean mpg of cars?
Mean(cars$mpg)
How do you find the column names in a data frame?
By printing the whole data frame
Names(name of data frame )
Only shows the column names of a data frame