STAT 220

Bastola

- R uses object-oriented programming (OOP) principles
- Functions in R are designed to work with specific object classes and types
- Example:
`plot()`

function behaves differently based on the input object

`plot()`

Function ExamplesDiagnostic plots with `plot()`

:

The `plot()`

function adapts its behavior based on the input object’s class and type

- R objects are based on vectors
- Two functions to examine objects:
`typeof()`

: Returns the storage mode (data type) of an object`class()`

: Provides further description of an object

- NULL: Represents an empty object (vector of length 0)

R uses two types of vectors to store info

**atomic vectors**: all entries have the same data type**lists**: entries can contain other objects that can differ in data type

Atomic vector (numeric):

You can add **attributes**, such as **dimension**, to vectors. A **matrix** is a 2-dimensional vector containing entries of the same type

**Creating a matrix with dimensions:**

Bind vectors of the same length to create columns or rows. Use `cbind()`

for column binding and `rbind()`

for row binding

Sum of Logical Values

Factors are a class of data that are stored as **integers**

The attribute `levels`

is a character vector of possible values

- Values are stored as the integers (1=first
`level`

, 2=second`level`

, etc.) - Levels are ordered alphabetically/numerically (unless specified otherwise)

- are a new modern data frame
- never changes the input data types
- can have columns that are lists
- can have non-standard variable names
- can start with a number or contain spaces

- One
`[]`

operator gives you the object at the given location but preserves the list type `my_list[2]`

returns a list of length one with entry`myDf`

`20:00`