-R object
In R the variables are not declared as data type but as objects. The data type of the R-object becomes the data type of the variable.
There are many types of R-objects. The frequently used ones are Vectors, Matrices, Arrays, Data frame, List, and Factor
Vectors:
a <-c(1,2,3,4.9,10,2,4) # numeric
vectorb <-c("one","two","three") # character
vectorc <-c(TRUE,FALSE) #logical vectora;b;c b[c(1,2)] # 1st and 2nd elements of vector bMatrix:
c<- matrix(
c(1:6), # the data elements
nrow=2, # number of rows
ncol=3, # number of columns
byrow = TRUE) # fill matrix by rows
c # print the matrix
#####################
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6Array:
Data frame:
List:
Factor and Order
Last updated