Learning basic knowledge of R language (i): data types and structures in R

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.