Please enable JavaScript.
Coggle requires JavaScript to display documents.
Introduction to R (Intro to Basics (Arithmetic with R, Variable Assignment…
-
One Dimensional
- Nominal variable is a categorical variable without an implied order.
- Ordinal variables do have a natural ordering
Summarizing a factor
- Overview of the content: summary(my_var)
- Factor: refers to a statistical data type used to store categorical variables
- Two types of categorical variables: a nominal categorical variable and an ordinal categorical variable.
- Vectors are one-dimension arrays that can hold numeric data, character data, or logical data.
- In other words, a vector is a simple tool to store data.
- Create a vector with the combine function c()
Two Dimensional
- A data frame has the variables of a data set as columns and the observations as rows
- The function str() shows you the structure of your data set
-
- subset(my_df, subset = some_condition)
- The function rowSums() conveniently calculates the totals for each row of a matrix. i.e. factor().
cbind(), rbind(), colSums(), rowSums()
Matrix Selection:
- my_matrix[1,2] selects the element at the first row and second column.
- my_matrix [1:3,2:4] results in a matrix with the data on the rows 1, 2, 3 and columns 2, 3, 4.
- my_matrix[,1] selects all elements of the first column.
- my_matrix[1,] selects all elements of the first row.
- In R, a matrix is a collection of elements of the same data type (numeric, character, or logical) arranged into a fixed number of rows and columns. Since you are only working with rows and columns, a matrix is called two-dimensional.
- Construct a matrix in R with the matrix() function.
- matrix(1:9, byrow = TRUE, nrow = 3)
Multi Dimentional
- 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.
- Print the second element of the vector:
list_name$vector[2]
-
-
-