美文网首页R 语言学习笔记
R语言入门学习笔记(2)

R语言入门学习笔记(2)

作者: DC小白 | 来源:发表于2019-10-04 12:01 被阅读0次

课程源代码:https://github.com/miwu8512/IntroToR

视频地址: https://www.youtube.com/watch?v=rPj5FsTRboE&list=PLBTcf4SwWEI9_kCOJ-1o-Jwr-_Qb6bkeg

Lecture 2 数据集的结构和作图的主要变量

1 understanding the dataset

1.1 Vector 向量

Define: Vectors are one-dimersional arrays that can hold nurmeric, character, logical data.
Function:

c()
a = c(1,2,-3,4)
b = c("one","two")
c = c(TRUE,TRUE,FALSE,TRUE)

1.2 Matrix 矩阵

Define: Matrix is a two-dimersional array where each element has th esame mode(nurmeric, character, or logical).
Function:

matrix() 

x = matrix (1:20,nrow=5,ncol=4,byrow=TRUE)

> x
      [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
[4,]   13   14   15   16
[5,]   17   18   19   20

x[2,]   #返回第二行数据
x[,2]   #返回第二列数据
x[1,4]
x[2,c(2,4)]
x[3:5,2]
rnames=c("apple","banana","orange","melon","corn")
cnames=c("cat","dog","bird","pig")
rownames(x)=rnames
colnames(x)=cnames

1.3 Array 数组

Define: Arrays are similar to matrics but can have more than two dimensions.
Function:

array()

dim1 = c("A1","A2")
dim2 = c("B1","B2","B3")
dim3 = c("C1","C2","C3","C4")
dim4 = c("D1","D2","D3") 
z = array(1:72,c(2,3,4,3), dimnames=list(dim1,dim2,dim3,dim4))

1.4 data frame

Define: A data frame is more general than a matrix in that different columns can cantain different modes of data(numeric, character, etc.). It is similar to the datasets you would typically see in SAS, SPSS, and Stata.

1.5 attach and detach

1.6 list

Define: Lists are the most complex of the R data types. A list allows you to gather a variety of (possible unrelated) objects under one name.

2 Graphs 作图

2.1 Graphical parameters

Define: customize many features of a graph (fonts,colors,axes,titles) through options called graphical parameters.
Function:

par() 

par(mfrow=c(2,2))  #设定多图布局网格
plot(rnorm(50),pch=19)          #pch:point的形状
plot(rnorm(20),type="l",lty=5)  #lty:line type 线的形状
plot(rnorm(100),cex=0.5)        #cex:放大比例
plot(rnorm(200),lwd=2)          #lwd: line width 粗细变换

2.2 title, axes, legends

title()  #标题
axis()   #坐标轴
legend() #图例

2.3 layout 布局

Define: layout() function has the form layout(mat) where mat is a matrix object specifying the location of the multiple plots to combine.

> attach(mtcars)
> layout(matrix(c(1,1,2,3),2,2,byrow= TRUE)) 
> hist(wt)
> hist(mpg)
> hist(disp)
> detach(mtcars)

相关文章

  • 学习小组Day4笔记--行

    正式开始学习R语言了,今天笔记内容为R语言基础和ggplot2的入门学习 R语言基础 1、认识R与RStudio ...

  • R语言入门学习笔记(2)

    课程源代码:https://github.com/miwu8512/IntroToR 视频地址: https://...

  • 学习小组Day4笔记--扬马延

    R语言学习 1. R以及R studio安装 直接搜索R语言网页可直接安装 2. R语言入门 参考书目《R for...

  • 一、R与Rstudio

    R语言——生信入门第一步 生信技能树数据挖掘课程学习笔记 一、R与Rstudio 1.什么是R? 2.什么是RSt...

  • R 语言实战 读书笔记

    R语言实战(第2版) 学习笔记 1. R语言介绍 1.1 为什么用R语言 bla 1.2 基本操作 图表演示命令 ...

  • R 语言--日期值的输入

    学习R语言,很多人都推荐使用图灵程序设计丛书中的"R in Action"-《R语言实战》作为R语言学习的入门书籍...

  • DAY7+ 学习笔记 by 康康

    《R与tidyverse——数据分析入门》学习笔记 R与tidyverse——数据分析入门[https://tia...

  • 65-R语言训练深度预测模型

    《深度学习精要(基于R语言)》学习笔记 1、概览 本文涉及以下主题:• 深度前馈神经网络入门• 常见的激活函数:整...

  • R语言入门笔记(2) - R语言科学计算

    R语言科学计算 分类统计 mean(),求平均值 min(),求最小值 sd(),求标准差 数组和矩阵 数组与矩阵...

  • R语言入门学习笔记(3)

    课程源代码:https://github.com/miwu8512/IntroToR 视频地址: https://...

网友评论

    本文标题:R语言入门学习笔记(2)

    本文链接:https://www.haomeiwen.com/subject/wylductx.html