installed.packages() or library()

ls() or objects() to list the objects currently in the memory
rm(i) to remove object i from the memory

Names in R are case sensitive.

All objects have mode and length. The mode determines the kind of data stored in the object. The length of an object is the number of elements in it and can be obtained with the function length().

c() combines its arguments to form a vector. v <- c(4, 7, 1, 2). length(v), mode(v)

missing value is represented by NA

x <- vector() to create an empty vector

Factors provide an easy and compact form of handling categorical (nominal) data. Factors have levels that are the possible values they can take. Factors are particularly useful when you have nominal variables with a fixed number of possible values.


The table() function can be used to obtain cross-tabulation of several factors.

x <- 1:1000 for sequence generation
To generate real numbers, you can use the function seq(). seq (-4, 1, 0.5)

rep() generates sequences with a certain pattern.

The function gl() can be used to generate sequences involving factors.
gl(k, n) where k is the number of levels of the factor and n is the number of repetitions of each level.

gl(2, 5, labels=c("female", "male"))

R has several functions that can be used to generate random sequences according to different prbability density functions. The functions have the generic structure rfunc(n, par1, par2, ....) where func is the name of the probability distribution, n is the number of data to generate and par1, par2, .... are the values of some parameters of the density function that may be required.

You can use a vector with negative indexes to indicate which elements are to be excluded from the selection.

R allows you to name the element of a vector through the function names().

Matrices are a special case of arrays with two single dimensions. Arrays and Matrices in R are nothing more than vectors with a particular attribute that is dimension.

Functions cbind() and rbind() may be used to join together two or more vectors or matrices, by columns or by rows, respectively.

Arrays are extensions of matrices to more than two dimensions. This means that they have more than two indexes. Similar to the matrix() function, there is an array() function to facilitate the creation of arrays.

R lists consists of an ordered collection of other objects known as their components. Unlike the elements of vectors, list components do not need to be of the same type, mode, or length.

Data frames are the data structure most indicated for storing data tables in R. They are similar to matrices in structure as they are also bi-dimensional. However, contrary to matrices, data frames may include data of a different type in each column. In this sense they are more similar to lists, and in effect, for R, data frames are a special class of lists.
We can think of each row of a data frame as an observation (or case), being described by a set of variables (the named columns of the data frame).