Data Structures in R Flashcards
5 Basic Data Structures in R?
Vector, Factor, List, Matrix, Data Frame
A type of array that is one-dimensional.
Vector
How to create a vector using syntax?
c(<element>)</element>
Refers to a statistical data type used to store categorical variables.
Factor
What syntax do you use to create a factor?
factor(<vector>)</vector>
What additional arguments do you add to create an ordered factor?
Ordered and Levels
This is the best choice to use when data cannot be represented as an array or a data frame.
list
What syntax do you use in creating a list?
list(<arguments>)</arguments>
Is a two-dimensional array of numbers having a fixed numbers of rows and columns.
Matrix
What syntax do you use to create a matrix directly from a data frame?
table(<vector>, <vector>)</vector></vector>
Is a table or a two-dimensional array-like structure in which each column contains values of one varibale and each row contains one set of values from each column.
Data Frame
4 characteristics of Data Frame
Column names should be non-empty, row names should be unique, data stored in a data frame can be numeric, factor or character type, and each column should contain same number of data items
This operator is used to denote multiple conditions.
&
This function determines the number of rows in an object such as matrix, data frame, or even a dataset.
nrow
The syntax to use when creating a subset?
subset(<dataname>, <condition>)</condition></dataname>