Programming in R Flashcards
Five basic or “atomic” classes of objects in R
- Character
- Numeric (Real Numbers)
- Integer
- Complex
- Logical (True/False)
The most basic object in R
A Vector - can only contain objects of the same class (except lists)
- Empty vectors can be created with the “vector()” function
Attributes of R objects?
- Names, dimness (dimension names)
- Dimensions (matrices, arrays)
- Class
- Length
- Other
- Accessible using the “attributes()” function
What operator is used in R to create an integer sequence?
A colon eg. [1:20]
What is “coercion” in R?
This is when objects in R are mixed in the same vector and so R simplifies to the least common denominator to make them of the same class
What is a matrix in R?
A matrix is a veto with a dimension attribute. The dimension is itself an integer vector of length 2 (now, ncos)
Matrices are constructed “column-wise” starts at the top of a column and goes down through rwo, then start top of next column until complete.
Whit is cbind-ing and rbinding of matrices in R?
Column-binding and row-binding with cbind() and rbind(); cbind() lists the objects in a vertical order, rbind() in a horizontal order
What is a list in R?
Lists are a special type of vector in R that can contain elements of different classes. lists are very important in R. and used for many things. Elements in lists have double brackets around them.
What is a “Factor” in R?
A Factor represents categorical data that is ordered or unordered, like an integer vector where each integer has a label (eg/ Male and Female instead of 1 and 2.