Data structures

Create & delete variables


# create a variable

x=5

# show (list) all variables

ls()

"x"

# delete a variable

rm(x)

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

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 to matrix

z = as.matrix(y)

class(z)

"matrix"



Read more

→ data.frame