Data structures

# create & delete variables

x=5 # create variable

ls() # show (list) all variables

"x"

rm(x) # delete variable

# clear (clean up) - delete all variables in R

rm(list=ls())

# check data type of a variable

x = 5

typeof(x)

"double"

class(x)

"numeric"

y = data.frame("A" = c(12,52,14), "B" = c(81,32,65))

typeof(y)

"list"

class(y)

"data.frame"

# convert data.frame into numerical matrix (double)

z = data.matrix(y)

typeof(z)

"double"

class(z)

"matrix"