# R Programming Fundamentals

## Seq Function

## Unsorted

- getwd() - returns working directory.
- setwd(“E:\STA4502\RCode”) - set the working directory to “E:\STA4502\RCode.
- cbind(x,y) - combine two vectors of same length (x,y) to make a matrix

- data.frame(x,y) - combine two vectors of different types into a dataframe while preserving the original variables’ datatypes. Dataframes can handle different length vectors.
- M = matrix(1:20, nrow = 4, ncol = 5)
- W = list(Matrix, charVector, intVector) - lists can handle basically all types of parameters.

## Cleaning

### Ctrl + L

- clears the R console
- this does not remove the variables from memory.

- rm(list=ls()) - this will erase the memory.

## Var Types

- character
- numeric (real numbers)
- integer
- complex
- logical (True/False)

## Vectors

Vectors are the most basic R object. An empty vector may be created with vector().

Vectors may only contain objects of the same class.

Lists, while represented as a vector, can break the rule above and contain objects of different classes.

The c() function can be used to create vectors by concatenating things together.

## Dataframes, Matrices, and Lists

Data frames are standard data objects and are used to combine several variables of the same length and of potentially differing types into a single unit.

## Commenting

Commenting is done like python, with #.

## Install Packages

## Call Data

To see the collection of all datasets in a package.

## library() function

library() invisibly returns the list of attached packages.

## help() function

help() returns a short description of what is included within the data.