The data types in R are: numeric, character, logical and plural.
The structure of data stored in R is: vectors, arrays, factors, data frames, matrices, and lists.
Vectors are one-dimensional arrays for storing numeric, character, or logical data.
Use the function C () to create a vector, such as:
> A <-C (1,2,3,4)
> B <-C (' China ', ' America ', ' Japan ')
> C <-C (true,false,true,false)
> ls ()
[1] "a" "B" "C"
> Ls.str ()
A:num [1:4] 1 2 3 4
B:CHR [1:3] "China" "America" "Japan"
C:logi [1:4] true false true False
The code above defines three vectors, and a,b,c stores numeric, character, and logical variables respectively.
A data frame is a structure used to store data in R: Columns represent variables, rows represent observations, and variables of different types (such as numeric, character) can be stored in the same data frame.
Learning basic knowledge of R language (i): data types and structures in R