R Language Practical reading notes (ii) creating datasets

Source: Internet
Author: User

2.2.2 Matrix

Matrix (Vector,nrow,ncol,byrow,dimnames,char_vector_rownames,char_vector_colnames)

which

Byrow=true/false, which is filled by row or column, is populated by column by default

2.2.4 Data Frame

1.attach,detach () and with ()

Attach (): Add data frame to search path

Detach (): Remove the data frame from the search path

With (): assignment is only valid in parentheses, if you want to take effect outside of parentheses, use <<-

2.2.5 Factor

Factor: A nominal variable and an ordered variable that corresponds to an integer value for such a variable

Factor (): Generates a factor vector, ordered=true after an ordered variable, levels parameter overrides the default sort, you can specify the order of ordinal variables corresponding to integer values

Usage:

Patientid <-C (1, 2, 3, 4)
Age <-C (25, 34, 28, 52)
Diabetes <-C ("Type1", "Type2", "Type1", "Type1")
Status <-C ("Poor", "improved", "excellent", "Poor")
Diabetes <-Factor (Diabetes) #会被编成1 2 1 1
Status <-factor (status, order = TRUE) #会被编成3 2 1 3
Patientdata <-Data.frame (Patientid, age, diabetes, status)
STR (patientdata) #str是显示对象结构 that can be shown to be encoded into what
Summary (Patientdata)

2.2.6 List

G <-"My first List"
H <-C (25, 26, 18, 39)
J <-Matrix (1:10, nrow = 5)
K <-C ("One", "one", "one", "three")
MyList <-List (title = g, ages = h, j, K)
MyList

2.3.2 importing data from a delimited text file

Read.table (File,header,sep,row.nanes), by default, character variables are converted to factors that can be set Stringsasfactors=false

2.5 Practical functions for processing data Objects, after reading the machine learning practice, I think these are pediatrics.

Length ()

Dim (): Display the dimensions of an object

STR (): Shows the structure of the object, R language This pit is dead named Ah, STR is not generally referred to as a string, so it becomes structure

Class ()

Names ()

Cbind ()

Rbind ()

Head ()

Tail ()

R Language Practical reading notes (ii) creating datasets

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.