Arguments Flashcards
How do you create a vector?
c (…)
How do you calculate the sum of all elements in a vector?
Sum (any_vector)
How do you create a matrix?
matrix(…)
How do you fill in the data by row in a matrix?
byrow = TRUE
How do you indicate the number of rows in a matrix?
nrow =
How do you calculate the totals for each row of a matrix?
rowSums (any_matrix)
How do you had a column or multiple columns to a matrix?
cbind( any matrix or vector)
How do you check the contents of a workspace?
ls ( )
How do you select all elements of a row or column?
any_matrix [1,] or any_matrix [,1]
What is a factor?
A factor refers to a statistical data type used to store categorical variables.
What is a categorical variable?
A variable that can belong to a limited number of categories.
What is a continuous variable?
A variable that can belong to an infinite number of values.
What is a nominal variable?
A variable without an implied order
What is a nominal variable?
A variable with an implied order. (High, Medium, Low)
How do you tell a vector that it is nominal or ordered?
factor( any_vector, order = TRUE, levels = c (“High”, “Medium”, “Low”)
How do you specify the levels when creating a vector?
levels ( )
How do you get the sum total of each factor in the data set?
summary(any vector or matrix)
how do you show only the first observations in a data frame?
head ( any matrix or vector)
how do you get the last observations in a data set?
tail (any vector or matrix)
What does str( ) do?
Tells you: Total number of observations Total number of variables Full list of variable names Data type of each variable The first observations
Vectors
(one dimensional array): can hold numeric, character or logical values. The elements in a vector all have the same data type
Matrices
(two dimensional array): can hold numeric, character or logical values. The elements in a matrix all have the same data type.
Data Frames
(two-dimensional objects): can hold numeric, character or logical values. Within a column all elements have the same data type, but different columns can be of different data type.
A list in R
allows you to gather a variety of objects under one name (that is, the name of the list) in an ordered way. These objects can be matrices, vectors, data frames, even other lists, etc. It is not even required that these objects are related to each other in any way.
what does == do?
checks the equality of two variables and outputs TRUE or FALSE
trim = x/y
trim =, takes whatever fraction you input and applies it to the number of data inputs, and then removes that number from both the beginning and ending or highest and lowest points of the data inputs.