Several data structure _r languages in R language

Source: Internet
Author: User

5 basic types of objects in a R

Character (character) integer (integer) complex (complex) logical (Logical:true/false) value (numeric:real numbers)

To view the command for an object type: Class (X)


There are several data structures in the two R languages:

The elements within vector vectors () groups must be of the same type, otherwise they will be cast.
(1) Three ways to create vectors:

<span style= "FONT-SIZE:18PX;" >x <-vector ("numeric", length = ten)

x <-1:4

x <-C ("a", 12,true) </span>
(2) Several functions of the cast:
As.numeric (x)/As.character (x)/as.logical (x) matrices matrix () a column of filled elements
Merge by row: Rbind () Merge by column: Cbind () array () can have more than one dimension list () can contain different types of element factors factor ()
(1) Categorical data/order vs. disorder
(2) Integer vector + label (label) (better than integer vector)
Male/female vs. 1/2
Commonly used in LM (), GLM ()
(3) Levels set baseline level
Table () View factor Information Unclass () remove factor attribute

Date
x <-sys.date () get the system current date
Julian (x) x distance from 1970-01-01 days posixct/posixlt
Posixct: integer, often used to deposit data box as. Posixct ()
Posixlt: List, also contains information such as week, month, day, etc. As. Posixlt ()
Strptime (x, format = "...") converts a generic format to a time format

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.