《R語(yǔ)言實(shí)戰(zhàn)》學(xué)習(xí)筆記

2017年夏天開(kāi)始學(xué)習(xí)R語(yǔ)言。

第1章 R語(yǔ)言介紹

1.1 R的獲取和安裝

下載Rgui:http://cran.r-project.org
可以通過(guò)安裝包(package)的可選模塊來(lái)增強(qiáng)R的功能。
下載RStudio:https://www.rstudio.com/products/rstudio/download/#download

1.3 R的使用

  • R是一種區(qū)分大小寫(xiě)的解釋性語(yǔ)言。
  • R使用<-作為賦值符號(hào),而不是傳統(tǒng)的=。
  • 注釋由#開(kāi)頭。
  • R不提供多行注釋功能,可以用if(FALSE){}存放被忽略的代碼。
  • R會(huì)自動(dòng)拓展數(shù)據(jù)結(jié)構(gòu)以容納新值。
  • R的下標(biāo)從1開(kāi)始。
  • 變量無(wú)法被聲明,它們?cè)谑状钨x值時(shí)生成。
  • Google's R Style Guide: https://google.github.io/styleguide/Rguide.xml
  • 搜索“來(lái)自Google的R語(yǔ)言編碼風(fēng)格指南”可以找到這份文檔的中文版
  • R programming for those coming from other languages: https://www.johndcook.com/R_language_for_programmers.html

1.3.1 獲取幫助 P10

  • help.start() 打開(kāi)幫助文檔首頁(yè)

1.3.2 工作空間 P11

  • getwd() 查看當(dāng)前工作目錄
  • setwd() 設(shè)定當(dāng)前工作目錄
  • dir.create() 創(chuàng)建新目錄
  • 路徑使用正斜桿/
  • 命令的歷史紀(jì)錄保存到文件.Rhistory
  • 工作空間保存到當(dāng)前目錄中的文件.RData
  • q() 退出R

1.3.3 輸入和輸出

  • 輸入:source("filename")
  • 文本輸出:sink("filename")
    參數(shù)append = TRUE追加文本而非覆蓋
    參數(shù)split = TRUE將輸出同時(shí)發(fā)送到屏幕和輸出文件中
    無(wú)參數(shù)調(diào)用sink() 僅向屏幕返回輸出結(jié)果
  • 圖形輸出 P12

1.5 批處理 P15

1.6 將輸出用為輸入:結(jié)果的重用 P16

lmfit <- lm(mpg~wt, date = mtcars)

第2章 創(chuàng)建數(shù)據(jù)集

2.1 數(shù)據(jù)集的概念

數(shù)據(jù)構(gòu)成的矩形數(shù)組,行表示觀測(cè),列表示變量。

2.2 數(shù)據(jù)結(jié)構(gòu)

2.2.1 向量

向量是用于存儲(chǔ)數(shù)值型、字符型或邏輯型數(shù)據(jù)的一維數(shù)組。
創(chuàng)建向量:c()

  • 單個(gè)向量中的數(shù)據(jù)必須擁有相同的類(lèi)型或模式(數(shù)值、字符、邏輯)
  • 標(biāo)量是只含一個(gè)元素的向量,用于保存常量
  • 訪問(wèn)向量中的元素:
> a <- c("k", "j", "h", "a", "b", "m")
> a[3]
[1] "h"
> a[c(1,3,5)]
[1] "k" "h" "b"
> a[1,3,5]
Error in a[1, 3, 5] : 量度數(shù)目不對(duì)
> a[2:6]
[1] "j" "h" "a" "b" "m"

2.2.2 矩陣 P22

矩陣是一個(gè)二維數(shù)組,每個(gè)元素?fù)碛邢嗤哪J健?br> 創(chuàng)建矩陣:matrix(矩陣元素, nrow = 行數(shù), ncol = 列數(shù), byrow = FALSE 默認(rèn)按列填充<可選>, dimnames = list(行名, 列名)<可選>)

> y <- matrix(1:20, nrow = 5, ncol = 4)
> y
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17
[3,]    3    8   13   18
[4,]    4    9   14   19
[5,]    5   10   15   20
> cells <- c(1, 26, 24, 68)
> rnames <- c("R1", "R2")
> cnames <- c("C1", "C2")
> mymatrix <- matrix(cells, nrow = 2, ncol = 2, byrow = TRUE, dimnames = list(rnames, cnames))
> mymatrix
   C1 C2
R1  1 26
R2 24 68

矩陣下標(biāo)的使用:
X[i, ] 矩陣X中的第i行
X[, j] 矩陣X中的第j列
X[i, j] 矩陣X中的第i行第j個(gè)元素
選擇多行或多列,下標(biāo)i和j可為數(shù)值型向量。

> x <- matrix(1:10, nrow = 2)
> x
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10
> x[2, ]
[1]  2  4  6  8 10
> x[, 2]
[1] 3 4
> x[1, 4]
[1] 7
> x[1, c(4,5)]
[1] 7 9

2.2.3 數(shù)組

數(shù)組和矩陣類(lèi)似,但是維度可以大于2。
創(chuàng)建數(shù)組:array(vector, dimensions, dimnames<可選>)

> dim1 <- c("A1", "A2")
> dim2 <- c("B1", "B2", "B3")
> dim3 <- c("C1", "C2", "C3", "C4")
> z <- array(1:24, c(2,3,4), dimnames = list(dim1, dim2, dim3))
> z
, , C1

   B1 B2 B3
A1  1  3  5
A2  2  4  6

, , C2

   B1 B2 B3
A1  7  9 11
A2  8 10 12

, , C3

   B1 B2 B3
A1 13 15 17
A2 14 16 18

, , C4

   B1 B2 B3
A1 19 21 23
A2 20 22 24

2.2.4 數(shù)據(jù)框

創(chuàng)建數(shù)據(jù)框:data.frame(col1, col2, col3, ...)

> patientID <- c(1, 2, 3, 4)
> age <- c(25, 34, 28, 52)
> diabetes <- c("Type1", "Type2", "Type1", "Type1")
> status <- c("Poor", "Improved", "Excellent", "Poor")
> patientdata <- data.frame(patientID, age, diabetes, status)
> patientdata
  patientID age diabetes    status
1         1  25    Type1      Poor
2         2  34    Type2  Improved
3         3  28    Type1 Excellent
4         4  52    Type1      Poor

選取數(shù)據(jù)框中的元素:

> patientdata[1:2]
  patientID age
1         1  25
2         2  34
3         3  28
4         4  52
> patientdata[c("diabetes", "status")]
  diabetes    status
1    Type1      Poor
2    Type2  Improved
3    Type1 Excellent
4    Type1      Poor
> patientdata$age
[1] 25 34 28 52
> table(patientdata$diabetes, patientdata$status)
       
        Excellent Improved Poor
  Type1         1        0    2
  Type2         0        1    0
  • attach()、detach()和with()
    函數(shù)attach() 可將數(shù)據(jù)框添加到R的搜索路徑中
summary(mtcars$mpg)
plot(mtcars$mpg, mtcars$disp)
plot(mtcars$mpg, mtcars$wt)
可寫(xiě)成
attach(mtcars)
    summary(mpg)
    plot(mpg, disp)
     plot(mpg, wt)
detach(mtcars)

函數(shù)detach() 將數(shù)據(jù)框從搜索路徑中移除。(可省略,為保持良好的編程習(xí)慣還是要寫(xiě)。)
環(huán)境中有重名對(duì)象時(shí)使用函數(shù)with() :

with(mtcars,{
    print(summary(mpg))
    plot(mpg, disp)
    plot(mpg, wt)
})
若要?jiǎng)?chuàng)建在with() 結(jié)構(gòu)意外的對(duì)象,使用特殊賦值符<<-代替<-
with(mtcars, {
    keepstats <<- summary(mpg)
})
  • 實(shí)例標(biāo)識(shí)符
    實(shí)例標(biāo)識(shí)符可通過(guò)數(shù)據(jù)框操作函數(shù)中的rowname選項(xiàng)指定。
patientdata <- data.frame(patientID, age, diabetes, status, row.names = patientID)

2.2.5 因子

變量可歸結(jié)為名義型、有序型或連續(xù)型變量。

  • 名義型變量沒(méi)有順序之分。如:Diabetes(Type1、Type2)
  • 有序型變量表示一種順序關(guān)系而非數(shù)量關(guān)系。如:Status(poor、improved、excellent)
  • 連續(xù)型變量呈現(xiàn)為某個(gè)范圍內(nèi)的任意值。如:Age
    因子:類(lèi)別(名義型)變量和有序類(lèi)別(有序型)變量。
    對(duì)于名義型變量:
diabetes <- c("Type1", "Type2", "Type1", "Type1")
語(yǔ)句diabetes <- factor(diabetes)將此向量存儲(chǔ)為(1, 2, 1, 1)
并在內(nèi)部將其關(guān)聯(lián)為1 = Type1和2 = Type2(具體賦值根據(jù)字母順序而定)

對(duì)于有序型變量,需要為函數(shù)factor() 指定參數(shù)ordered = TRUE:

satatus <- c("Poor", "Improved", "Excellent", "Poor")
語(yǔ)句status <- factor(status, ordered = TRUE)會(huì)將向量編碼為(3, 2, 1, 3)
默認(rèn)為字母順序排序,若要指定排序:
status <- factor(status, order = TRUE, levels = c("Poor", "Improved", "Excellent"))

對(duì)于數(shù)值型變量:

如果男性編碼成1,女性編碼成2:
sex <- factor(sex, levels = c(1, 2), labels = c("Male", "Female"))
標(biāo)簽"Male" 和"Female” 將代替1和2在結(jié)果中輸出

因子的使用:

> 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)
> status <- factor(status, ordered = TRUE)
> patientdata <- data.frame(patientID, age, diabetes, status)
> str(patientdata) #顯示數(shù)據(jù)框內(nèi)部編碼結(jié)構(gòu)
'data.frame':   4 obs. of  4 variables:
 $ patientID: num  1 2 3 4
 $ age      : num  25 34 28 52
 $ diabetes : Factor w/ 2 levels "Type1","Type2": 1 2 1 1
 $ status   : Ord.factor w/ 3 levels "Excellent"<"Improved"<..: 3 2 1 3
> summary(patientdata) #顯示對(duì)象的統(tǒng)計(jì)概要(區(qū)別對(duì)待各個(gè)變量)
   patientID         age         diabetes       status 
 Min.   :1.00   Min.   :25.00   Type1:3   Excellent:1  
 1st Qu.:1.75   1st Qu.:27.25   Type2:1   Improved :1  
 Median :2.50   Median :31.00             Poor     :2  
 Mean   :2.50   Mean   :34.75                          
 3rd Qu.:3.25   3rd Qu.:38.50                          
 Max.   :4.00   Max.   :52.00    

2.2.5 列表

列表就是一些對(duì)象的有序集合
創(chuàng)建列表:
mylist <- list(object1, objext2, ...)
mylist <- list(name1 = object1, name2 = object2, ...)

> g <- "My First List"
> h <- c(25, 26, 18, 39)
> j <- matrix(1:10, nrow = 5)
> k <- c("one", "two", "three")
> mylist <- list(title = g, ages = h, j, k)
> mylist
$title
[1] "My First List"

$ages
[1] 25 26 18 39

[[3]]
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

[[4]]
[1] "one"   "two"   "three"

> mylist[[2]]
[1] 25 26 18 39
> mylist[["ages"]]
[1] 25 26 18 39

2.3 數(shù)據(jù)的輸入

2.3.1使用鍵盤(pán)輸入數(shù)據(jù)

  1. R內(nèi)置文本編輯器
> mydata <- data.frame(age = numeric(0), gender = character(0), weight = numeric(0))
> mydata <- edit(mydata)
#語(yǔ)句mydata <- edit(mydata) 可以簡(jiǎn)便寫(xiě)為fix(mydata)
  1. 代碼中直接嵌入數(shù)據(jù)
> mydatatxt <- "
+ age gender weight
+ 25 m 166
+ 30 f 115
+ 18 f 120
+ "
> mydatatxt <- read.table(header = TRUE, text = mydatatxt)

2.3.2 從帶分隔符的文本導(dǎo)入數(shù)據(jù) P33

mydataframe <- read.table(file, options)
其中file是一個(gè)帶分隔符的ASCII文本文件,options是控制如何處理數(shù)據(jù)的選項(xiàng)。

2.3.3 導(dǎo)入Excel數(shù)據(jù)

  • 最好方式:在Excel中導(dǎo)出為逗號(hào)分隔文件csv,再用前文描述導(dǎo)入R。
  • 直接導(dǎo)入:xlsx包、xlsxjars和rJava包。P35

2.3.4 導(dǎo)入XML數(shù)據(jù)

www.omegahat.org/RSXML

2.3.5 從網(wǎng)頁(yè)抓取數(shù)據(jù)

2.3.6 導(dǎo)入SPSS數(shù)據(jù) P36

2.3.7 導(dǎo)入SAS數(shù)據(jù) P37

2.3.8 導(dǎo)入Stata數(shù)據(jù)

library(foreign)
mydataframe <- read.dta("mydata.dta")

2.3.9 導(dǎo)入NetCDF數(shù)據(jù) P38

2.3.10 導(dǎo)入HDF5數(shù)據(jù) p38

2.3.11 訪問(wèn)數(shù)據(jù)庫(kù)管理系統(tǒng) P38

2.3.12 通過(guò)Stat/ Transfer導(dǎo)入數(shù)據(jù)

www.stattransfer.com 數(shù)據(jù)轉(zhuǎn)換應(yīng)用程序。

2.4 數(shù)據(jù)集的標(biāo)注

2.4.1 變量標(biāo)簽

就是重命名:

names(patientdata)[2] <- "Age at hospitalization (in years)"

2.4.2 值標(biāo)簽

如果男性編碼成1,女性編碼成2:
sex <- factor(sex, levels = c(1, 2), labels = c("Male", "Female"))
標(biāo)簽"Male" 和"Female” 將代替1和2在結(jié)果中輸出

2.5 處理數(shù)據(jù)對(duì)象的實(shí)用函數(shù)

P41

第3章 圖形初階

3.1 使用圖形

保存圖形:代碼、用戶(hù)圖形界面保存。P44

3.3 圖形參數(shù)

修改圖形的特征。

> opar <- par(no.readonly = TRUE)
> par(lty = 2, pch = 17)
> par(opar)

3.3.1 符號(hào)和線(xiàn)條

  • pch 指定繪制點(diǎn)時(shí)只用的符號(hào)
  • cex 指定符號(hào)的大小
  • lty 指定線(xiàn)條的類(lèi)型
  • lwd 指定線(xiàn)條的寬度
> plot(dose, drugA, type = "b", lty = 3, lwd = 3, pch = 15, cex = 2)

3.3.2 顏色

#RColorBrewer創(chuàng)建吸引人的顏色配對(duì)
> install.packages("RColorBrewer")
> library(RColorBrewer)
> n <- 7
> mycolors <- brewer.pal(n,"Set1")
> barplot(rep(1, n), col = mycolors)
#彩虹漸變色
> n <- 10
> mycolors <- rainbow(n)
> pie(rep(1, n), labels = mycolors, col = mycolors)
#10階灰度色
> mygrays <- gray(0:n/n)
> pie(rep(1, n), labels = mygrays, col = mygrays)

3.3.3 文本屬性 P50

3.3.4 圖形尺寸與邊界尺寸

使用圖形參數(shù)控制圖形外觀:

> dose <- c(20, 30, 40, 45, 60)
> drugA <- c(16, 20, 27, 40, 60)
> drugB <- c(15, 18, 25, 31, 40)
> opar <- par(no.readonly = TRUE)
> par(pin = c(2, 3))
> par(lwd = 2, cex = 1.5)
> par(cex.axis = .75, font.axis = 3)
> plot(dose, drugA, type = "b", pch = 19, lty = 2, col = "red")
> plot(dose, drugB, type = "b", pch = 23, lty = 6, col = "blue", bg = "green")
> par(opar)

3.4 添加文本、自定義坐標(biāo)軸和圖例

3.4.1 標(biāo)題

title(main = "main title", col.main = "red", sub = "subtitle", col.sub = "blue", xlab = "x-axis laber", tlab = "y-axis laber", col.lab = "green", cex.lab = 0.75)

3.4.2 坐標(biāo)軸 P54

axis(side, at = , labers = , pos, lty = , col = , las = , tck = , ... )
> x <- c(1:10)
> y <- x
> z <- 10 / x
> opar <- par(no.readonly = TRUE)
> par(mar = c(5, 4, 4, 8) + 0.1)
> plot(x, y, type = "b", pch = 21, col = "red", yaxt = "n", lty = 3, ann = FALSE)
> lines(x, z, type = "b", pch = 22, col = "blue", lty = 2)
> axis(2, at = x, labels = x, col.axis = "red", las =2)
> axis(4, at = z, labels = round(z, digits = 2), col.axis = "blue", las = 2, cex.axis = 0.7, tck = -.01)
> mtext("y = 1 / x", side = 4, line = 3, cex.lab = 1, las = 2, col = "blue")
> title("An Example of Creative Axes", xlab = "X values", ylab = "Y = X")
> par(opar)

3.4.3 參考線(xiàn)

abline(h = tvalues, v = xvalues)
abline(h = c(1, 5, 7))
abline(v = seq(1, 10, 2), lyt = 2, col = "blue")

3.4.4 圖例

legend(location, title, legend, ...)
> dose <- c(20, 30, 40, 45, 60)
> drugA <- c(16, 20, 27, 40, 60)
> drugB <- c(15, 18, 25, 31, 40)
> opar <- par(no.readonly = TRUE)
> par(lwd = 2, cex = 1.5, font.lab = 2)
> plot(dose, drugA, type = "b", pch = 15, lty = 1, col = "red", ylim = c(0, 60), main = "Drug A vs. Drug B", xlab = "Drug Dosage", ylab = "Drug Response")
> lines(dose, drugB, type = "b", pch = 17, lty = 2, col = "blue")
> abline(h = c(30), lwd = 1.5, lty = 2, col = "gray")
> minor.tick(nx = 3, ny = 3, tick.ratio = 0.5)
> legend("topleft", inset = 0.5, title = "Drug Type", c("A","B"),lty = c(1, 2), pch = c(15, 17), col = c("red", "blue"))
> par(opar)

3.4.5 文本標(biāo)注

text(location, "text to place", pos, ...)
mtext("text to place", side, line = n, ...)

3.4.6 數(shù)學(xué)標(biāo)注 P61

plotmath()

3.5 圖形的組合

attach(mtcars)
opar <- par(no.readonly = TRUE)
par(mfrow = c(2, 2))
plot(...)
plot(...)
hist(...)
boxplot(...)
par(opar)
detach(mtcars)
attach(mycars)
layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE), widths = c(3,1), heights = c(1, 2))
hist(...)
hist(...)
hist(...)
detach(mtcars)

圖形布局的精細(xì)控制

opar <- par(no.readonly = TRUE)
par(fig = c(0, 0.8, 0, 0.8))
plot(...)
par(fig = c(0, 0.8, 0.55, 1), new = TRUE)
boxplot(...)
par(fig = c(0.65, 1, 0, 0.8, new = TRUE))
boxplot(...)
par(opar)

第4章 基本數(shù)據(jù)管理

4.2 創(chuàng)建新變量

可能需要?jiǎng)?chuàng)建新變量或者對(duì)現(xiàn)有的變量進(jìn)行變換。變量名 <- 表達(dá)式

mydata <- data.frame(x1 = c(2, 2, 6, 4), x2 = c(3, 4, 2, 8))
#方式一
mydata$sumx <- mydata$x1 + mydata$x2
mydata$meanx <- (mydata$x1 + mydata$x2) / 2
#方式二
attach(mydata)
mydata$sumx <- x1 + x2
mydata$meanx <- (x1 + x2) / 2
detach(mydata)
#方式三
mydata <- transform(mydata, sumx = x1 +x2, meanx = (x1 + x2) / 2)

4.3 變量的重編碼

leadership <- within(leadership, {
                                      agecat <- NA
                                      agecat[age >75] <- "Elder"
                                      agecat[age >= 75 & age <= 75] <- "Middle Aged"
                                      agecat[age < 55] <- "Young"})

其他實(shí)用的變量重編碼函數(shù):car包中的recode()、doBy包中的recodevar()、R自帶的cut()。

4.4 變量的重命名

  1. fix(leadership)調(diào)用交互式編輯器。
  2. names()函數(shù)重命名變量:
names(leadership)[2] <- "testDate"
names(leadership)[6:10] <- c("item1", "item2", "item3", "item4", "item5") 
  1. plyr包中的rename()函數(shù)可用于修改變量名:
library(plyr)
leadership <- rename(leadership, c(manager = "managerID", date = "testDate"))

4.5 缺失值

缺失值以符號(hào)NA(Not Available,不可用)表示。
函數(shù)is.na()允許檢測(cè)缺失值是否存在。

y <- c(1, 2, 3, NA)
is.na(y)
返回c(FALSE, FALSE, FALSE, TRUE)
is.na(leadership[,6:10])
#將數(shù)據(jù)框限定到第6到第10列

識(shí)別無(wú)限的或者不可能出現(xiàn)的數(shù)值用is.infinite()或is.nan()。

4.5.1 重編碼某些值為缺失值

要確保所有的缺失數(shù)據(jù)已在分析之前被妥善地編碼為缺失值。

leadership$age[leadership$age == 99] <- NA

4.5.2 在分析中排除缺失值

  • 多數(shù)的數(shù)值函數(shù)擁有一個(gè)na.rm = TRUE選項(xiàng),可以在計(jì)算之前移除缺失值并使用剩余值進(jìn)行計(jì)算:
x <- c(1, 2, NA, 3)
y <- sum(x, na.rm = TRUE)
  • na.omit()可以刪除所有含有缺失數(shù)據(jù)的行:
newdata <- na.omit(leadership)

4.6 日期值

as.Date(x, "input_format"),默認(rèn)輸入格式為yyyy-mm-dd。

dates <- as.Date(strDates, "%m/%d/%Y")
myformat <- "%m/%d/%y"
leadership$date <- as.Date(leadership$date, myformat)

Sys.Date()返回當(dāng)天的日期。
date()返回當(dāng)前的日期和時(shí)間。
可以使用函數(shù)format(x, format = "output_format")來(lái)輸出指定格式的日期值,并且可以提取日期值中的某些部分:

today <- Sys.Date()
format(today, format = "%B %d %Y")
format(today, format = "%A")

R的內(nèi)部存儲(chǔ)日期是使用自1970年1月1日以來(lái)的天數(shù)表示的,更早的日期表示為負(fù)數(shù)??梢栽谌掌谥瞪蠄?zhí)行算術(shù)運(yùn)算:

> startdate <- as.Date("2004-02-13")
> enddate <- as.Date("2011-01-22")
> days <- enddate - startdate
> days
Time difference of 2535 days

> today <- Sys.Date()
> dob <- as.Date("1996-09-05")
> difftime(today, dob, units = "days")
Time difference of 7640 days

4.6.1 將日期轉(zhuǎn)換為字符型變量

strDates <- as.character(dates)

4.7 類(lèi)型轉(zhuǎn)換 P78

> a <- c(1, 2, 3)
> a
[1] 1 2 3
> is.numeric(a)
[1] TRUE
> is.vector(a)
[1] TRUE
> a <- as.character(a)
> a
[1] "1" "2" "3"
> is.numeric(a)
[1] FALSE
> is.vector(a)
[1] TRUE
> is.character(a)
[1] TRUE

4.8 數(shù)據(jù)排序

order()函數(shù)對(duì)一個(gè)數(shù)據(jù)框進(jìn)行排序,默認(rèn)升序,在排序變量前邊加一個(gè)減號(hào)可得降序。

newdata <- leadership[order(leadership$age),]
#創(chuàng)建新的數(shù)據(jù)集,其中各行依照經(jīng)理人的年齡升序排序
attach(leadership)
newdata <- leadership[order(gender, age), ]
detach(leadreship)
#各行依照女性到男性、同樣性別中按年齡升序排序
attach(leadership)
newdata <- leadership[order(gender, -age), ]
detach(leadreship)
#各行依照女性到男性、同樣性別中按年齡降序排序

4.9 數(shù)據(jù)集的合并

4.9.1 向數(shù)據(jù)框添加列

橫向合并兩個(gè)數(shù)據(jù)框(數(shù)據(jù)集),使用merge()函數(shù)。

total <- merge(dataframeA, dataframeB, by = "ID")

total <- merge(dataframeA, dataframeB, by = c("ID", "Country"))

#如果直接橫向合并兩個(gè)矩陣或者數(shù)據(jù)框并且不指定一個(gè)公共索引用cbind()
total <- cbind(A, B)
#每個(gè)對(duì)象必須擁有相同的行數(shù),以同順序排序

4.9.3 向數(shù)據(jù)框添加行

縱向合并兩個(gè)數(shù)據(jù)框(數(shù)據(jù)集)使用rbind()函數(shù):

total <- rbind(dataframeA, dataframeB)

兩個(gè)數(shù)據(jù)框必須擁有相同的變量,不過(guò)順序不必一定相同。

4.10 數(shù)據(jù)集取子集

4.10.1 選入(保留)變量

newdata <- leadership[, c(6:10)]

myvars <- c("q1", "q2", "q3", "q4", "q5")
newdata <- leadership[myvars]

myvars <- paste("q", 1:5, sep=" ")
newdata <- leadership[myvars]

4.10.2 剔除(丟棄)變量

myvars <- names(leadership) %in% c("q3", "q4")
newdata <- leadership[!myvars]

#已知q3和q4是第8個(gè)和第9個(gè)變量的情況下,可以使用語(yǔ)句:
newdata <- leadership[c(-8, -9)]

#設(shè)置q3和q4兩列為未定義(NULL)亦是一種刪除方式,NULL和NA是不同的
leadership$q3 <- leadership$q4 <-NULL

4.10.3 選入觀測(cè)

newdata <- leadership[1:3, ]

newdata <- leadership[leadership$gender == "M" & leadership$age >30,]

leadership$data <- as.Date(LEADERSHIP$DATE, "%m/%d/%y")
startdate <- as.Date("2009-01-01")
enddate <- as.Date("2009-10-31")
newdata <- leadership[which(leadership$date) >= startdate & leadership$date <= enddate), ]

4.10.4 subset()函數(shù)

選擇變量和觀測(cè)最簡(jiǎn)單的方法。

newdata <- subset(leadership, age >= 35 | age < 24, select = c(q1, q2, q3, q4))
newdate <- subset(leadership, gender == "M" & age > 25, select = gender:q4)

4.10.5 隨機(jī)抽樣

sample()函數(shù)中的第一個(gè)參數(shù)是一個(gè)由要從中抽樣的元素組成的向量,第二個(gè)參數(shù)是要抽取的元素?cái)?shù)量, 第三個(gè)參數(shù)表示無(wú)放回抽樣。

mysample() <- leadership[sample(1:nrow(leadership), 3, replace = FALSE), ]

4.11 使用SQL語(yǔ)句操作數(shù)據(jù)框

library(sqldf)
newdf <- sqldf("select * from mtcars where carb = 1 order by mpg", row.names = TRUE)

sqldf("select avg(mpg) as avg_mpg, avg(disp) as avg_disp, gear from mtcars where cyl in (4, 6) group by gear")

第5章 高級(jí)數(shù)據(jù)管理

5.2 數(shù)值和字符處理函數(shù)

5.2.1 數(shù)學(xué)函數(shù) P86

5.2.2 統(tǒng)計(jì)函數(shù) P88

5.2.3 概率函數(shù) P90

 R中概率函數(shù)形如[dpqr]distribution_abbreviation()
#位于z = 1.96左側(cè)的標(biāo)準(zhǔn)正態(tài)曲線(xiàn)下方面積是多少?
> pnorm(1.96)
[1] 0.9750021
#均值為500,標(biāo)準(zhǔn)差為100的正態(tài)分布的0.9分位點(diǎn)值為多少?
> qnorm(.9, mean = 500, sd = 100)
[1] 628.1552
#生成50個(gè)均值為50,標(biāo)準(zhǔn)差為10的正態(tài)隨機(jī)數(shù)
> rnorm(50, mean = 50, sd = 10)
  1. 設(shè)定隨機(jī)數(shù)種子
    set.seed()顯示指定種子。runif()生成0到1區(qū)間上服從均勻分布的偽隨機(jī)數(shù)。
> runif(5)
[1] 0.6509069 0.9809366 0.2417076 0.4011322 0.1121973
> runif(5)
[1] 0.95703624 0.86061820 0.09811243 0.74588111 0.75219763
> set.seed(1234)
> runif(5)
[1] 0.1137034 0.6222994 0.6092747 0.6233794 0.8609154
> runif(5)
[1] 0.640310605 0.009495756 0.232550506 0.666083758 0.514251141
> set.seed(1234)
> runif(5)
[1] 0.1137034 0.6222994 0.6092747 0.6233794 0.8609154
  1. 生成多元正態(tài)數(shù)據(jù)
    MASS包中的mvrnorm()函數(shù):mvrnorm(n, mean, sigma)
    其中n是想要的樣本大小,mean為均值向量,而sigma是方差-協(xié)方差矩陣(或相關(guān)矩陣)
> library(MASS)
> options(digits = 3)
> set.seed(1234)

> mean <- c(230.7, 146.7, 3.6)
> sigma <- matrix(c(15360.8, 6721.2, -47.1, 6721.2, 4700.9, -16.5, -47.1, -16.5, 0.3), nrow = 3, ncol = 3)

> mydata <- mvrnorm(500, mean, sigma)
> mydata <- as.data.frame(mydata)
> names(mydata) <- c("y", "x1", "x2")

> dim(mydata)
[1] 500   3
> head(mydata, n = 10)
       y    x1   x2
1   98.8  41.3 3.43
2  244.5 205.2 3.80
3  375.7 186.7 2.51
4  -59.2  11.2 4.71
5  313.0 111.0 3.45
6  288.8 185.1 2.72
7  134.8 165.0 4.39
8  171.7  97.4 3.64
9  167.2 101.0 3.50
10 121.1  94.5 4.10

5.2.4 字符處理函數(shù) P93

5.2.5 其他實(shí)用函數(shù) P94

5.2.6 將函數(shù)應(yīng)用于矩陣和數(shù)據(jù)框

apply()函數(shù):apply(x, MARGIN, FUN, ...)
x為數(shù)據(jù)對(duì)象, MARGIN是維度的下標(biāo), FUN是制定的函數(shù),...包括了任何想傳遞給FUN的參數(shù)。在矩陣或數(shù)據(jù)框中,MARGIN = 1表示行, MARGIN = 2表示列。

5.4 控制流

5.4.1 重復(fù)和循環(huán)

  1. for結(jié)構(gòu)
#for (var in seq) statement
for (i in 1:10) print("Hello")
  1. while結(jié)構(gòu)
#while (cond) statement
i <- 10
while (i > 0) {print("Hello"); i <- i - 1}

5.4.2 條件執(zhí)行

  1. if-else結(jié)構(gòu)
#if (cond) statement
#if (cond) statement1 else statement2
if (is.character(grade)) grade <- as.factor(grade)
if (!is.factor(grade)) grade <- as.factor(grade) else print("Grade already is a factor")
  1. ifelse結(jié)構(gòu)
#ifelse(cond, statement1, statement2)
ifelse(score > 0.5, print("Passed"), print("Failed"))
outcome <- ifelse(score > 0.5, "Passed", "Failed")
  1. switch結(jié)構(gòu)
#switch(expr, ...)
> feelings <- c("sad", "afraid")
> for (i in feelings)
+     print(
+         switch(i, happy = "I am glad you are happy",
+                   afraid = "There is nothing to fear",
+                   sad = "Cheer up",
+                   angry = "Calm down now"
+         )
+     )
[1] "Cheer up"
[1] "There is nothing to fear"

5.5 用戶(hù)自編函數(shù)

myfunction <- function (arg1, arg2, ...) {
    statements
    return(object)
}

5.6 整合與重構(gòu)

5.6.1 轉(zhuǎn)置

使用函數(shù)t()對(duì)一個(gè)矩陣或數(shù)據(jù)框進(jìn)行轉(zhuǎn)置。數(shù)據(jù)框行名將變成變量(列)名。

> cars <- mtcars[1:5, 1:4]
> cars
                   mpg cyl disp  hp
Mazda RX4         21.0   6  160 110
Mazda RX4 Wag     21.0   6  160 110
Datsun 710        22.8   4  108  93
Hornet 4 Drive    21.4   6  258 110
Hornet Sportabout 18.7   8  360 175
> t(cars)
     Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive Hornet Sportabout
mpg         21            21       22.8           21.4              18.7
cyl          6             6        4.0            6.0               8.0
disp       160           160      108.0          258.0             360.0
hp         110           110       93.0          110.0             175.0

5.6.2 整合數(shù)據(jù)

使用一個(gè)或多個(gè)by變量和一個(gè)預(yù)先定義好的函數(shù)來(lái)折疊(collapse)數(shù)據(jù)。
調(diào)用格式為:aggregate(x, by, FUN)
其中x是待折疊的數(shù)據(jù)對(duì)象,by是一個(gè)變量名組成的列表,這些變量將被去掉以形成新的觀測(cè),而FUN則是用來(lái)計(jì)算描述性統(tǒng)計(jì)量的標(biāo)量函數(shù),他將被用來(lái)計(jì)算新觀測(cè)中的值。

> options(digits = 3)
> attach(mtcars)
> aggdata <- aggregate(mtcars, by = list(cyl, gear), FUN = mean, na.rm = TRUE)
> aggdata
  Group.1 Group.2  mpg cyl disp  hp drat   wt qsec  vs   am gear carb
1       4       3 21.5   4  120  97 3.70 2.46 20.0 1.0 0.00    3 1.00
2       6       3 19.8   6  242 108 2.92 3.34 19.8 1.0 0.00    3 1.00
3       8       3 15.1   8  358 194 3.12 4.10 17.1 0.0 0.00    3 3.08
4       4       4 26.9   4  103  76 4.11 2.38 19.6 1.0 0.75    4 1.50
5       6       4 19.8   6  164 116 3.91 3.09 17.7 0.5 0.50    4 4.00
6       4       5 28.2   4  108 102 4.10 1.83 16.8 0.5 1.00    5 2.00
7       6       5 19.7   6  145 175 3.62 2.77 15.5 0.0 1.00    5 6.00
8       8       5 15.4   8  326 300 3.88 3.37 14.6 0.0 1.00    5 6.00

5.6.3 reshape2 包

reshape2包是一套重構(gòu)和整合數(shù)據(jù)集的絕妙的萬(wàn)能工具。使用前需安裝。

  1. 融合 P106
  2. 重鑄 P106

第6章 基本圖形

6.1 條形圖

barplot(height)
其中的height是一個(gè)向量或一個(gè)矩陣。使用參數(shù)horiz = TRUE生成水平條形圖。

6.1.1 簡(jiǎn)單的條形圖

> library(grid)
> library(vcd)
> counts <- table(Arthritis$Improved)
> counts

  None   Some Marked 
    42     14     28 
> barplot(counts, main = "Simple Bar Plot", xlab = "Improvement", ylab = "Frequency")
> barplot(counts, main = "Horizontal Bar Plot", xlab = "Frequency", ylab = "Improvement", horiz = TRUE)

若要繪制的類(lèi)別型變量是一個(gè)因子或有序型因子,可以用plot()快速創(chuàng)建垂直條形圖,無(wú)需使用table()將其表格化:

> plot(Arthritis$Improved, main = "Simple Bar Plot", xlab = "Improvement", ylab = "Frequency")
> plot(Arthritis$Improved, main = "Horizontal Bar Plot", xlab = "Frequency", ylab = "Improvement", horiz = TRUE)

6.1.2 堆砌條形圖和分組條形圖

如果height是矩陣,繪圖結(jié)果是堆砌條形圖或分組條形圖(beside = TRUE)。

> barplot(counts, main = "Stacked Bar Plot", xlab = "Treatment", ylab = "Frequency", col = c("red", "yellow", "green"), legend = rownames(counts))
> barplot(counts, main = "Grouped Bar Plot", xlab = "Treatment", ylab = "Frequency", col = c("red", "yellow", "green"), legend = rownames(counts), beside = TRUE)

6.1.3 均值條形圖

可以使用數(shù)據(jù)整合函數(shù)將結(jié)果傳遞給barplot()函數(shù),來(lái)創(chuàng)建表示均值、中位數(shù)、標(biāo)準(zhǔn)差等的條形圖。

> states <- data.frame(state.region, state.x77)
> means <- aggregate(states$Illiteracy, by = list(state.region), FUN = mean)
> means
        Group.1        x
1     Northeast 1.000000
2         South 1.737500
3 North Central 0.700000
4          West 1.023077
> means <- means[order(means$x),]
> means
        Group.1        x
3 North Central 0.700000
1     Northeast 1.000000
4          West 1.023077
2         South 1.737500
> barplot(means$x, names.arg = means$Group.1)
> title("Mean Illiteracy Rate")

6.1.4 條形圖的微調(diào)

#增加y邊界的大小
> par(mar = c(5, 8, 4, 2))
#旋轉(zhuǎn)條形的標(biāo)簽
> par(las = 2)
> counts <- table(Arthritis$Improved)
#縮小字體大小,修改標(biāo)簽文本
> barplot(counts, main = "Treatment Outcome", horiz = TRUE, cex.names = 0.8, names.arg = c("No Improvement", "Some Improvement", "Marked Improvement"))

6.1.5 棘狀圖

對(duì)堆砌條形圖進(jìn)行重縮放,每個(gè)條形的高度均為1,每一段的高度即表示比例。
由vcd包中的函數(shù)spine()繪制。

> par(mar = c(5, 8, 4, 2))
> par(las = 2)
> counts <- table(Arthritis$Improved)
> barplot(counts, main = "Treatment Outcome", horiz = TRUE, cex.names = 0.8, names.arg = c("No Improvement", "Some Improvement", "Marked Improvement"))

6.2 餅圖

更推薦使用條形圖或點(diǎn)圖,相對(duì)于面積人們對(duì)長(zhǎng)度的判斷更精確。
pie(x, labels)
其中x是一個(gè)非負(fù)數(shù)值向量,表示每個(gè)扇形的面積,labels則是表示各扇形標(biāo)簽的字符型向量。

> par(mfrow = c(2, 2)) #四幅圖形組合成一幅
> slices <- c(10, 12, 4, 16, 8)
> lbls <- c("US", "UK", "Australia", "Germany", "France")
> pie(slices, labels = lbls, main = "Simple Pie Chart")
 
> pct <- round(slices / sum(slices) * 100)
> lbls2 <- paste(lbls, " ", pct, "%", sep = "")
> pie(slices, labels = lbls2, col = rainbow(length(lbls2)), main = "Pie Chart with Percentages")

> library(plotrix)
> pie3D(slices, labels = lbls, explode = 0.1, main = "3D Pie Chart")

> mytable <- table(state.region) #從表格創(chuàng)建餅圖
> lbls3 <- paste(names(mytable), "\n", mytable, sep = "")
> pie(mytable, labels = lbls3, main = "Pie Chart from a Table\n (with sample sizes)")

餅圖難以比較值,扇形圖提供了一種同時(shí)展示相對(duì)數(shù)量和相互差異的方法。
plotrix中的包fan.plot()實(shí)現(xiàn)。

> library(plotrix)
> slices <- c(10, 12, 4, 16, 8)
> lbls <- c("US", "UK", "Australia", "Germany", "France")
> fan.plot(slices, labels = lbls, main = "Fan Plot")

6.3 直方圖

直方圖描述連續(xù)型變量的分布,通過(guò)在x軸上將值域分割為一定數(shù)量的組,在y軸上顯示相應(yīng)值的頻數(shù)。
hist(x)
其中x是一個(gè)由數(shù)據(jù)值組成的數(shù)值向量。參數(shù)freq = FALSE表示根據(jù)概率密度而不是頻數(shù)繪制圖形。參數(shù)breaks用于控制組的數(shù)量。

> par(mfrow = c(2, 2))
> hist(mtcars$mpg)
> mtcars$mpg
#指定組數(shù)和顏色
> hist(mtcars$mpg, breaks = 12, col = "red", xlab = "Miles Per Gallon", main = "Colored histogram with 12 bins")
#添加軸須圖
> hist(mtcars$mpg, freq = FALSE, breaks = 12, col = "red", xlab = "Miles Per Gallon", main = "Histogram, rug plot, density curve")
> rug(jitter(mtcars$mpg))
> lines(density(mtcars$mpg), col = "blue", lwd = 2)
#添加正態(tài)密度曲線(xiàn)和外框
> x <- mtcars$mpg
> h <- hist(x, breaks = 12, col = "red", xlab = "Miles Per Gallon", main = "Histogram with normal curve and box")
> xfit <- seq(min(x), max(x), length = 40)
> yfit <- dnorm(xfit, mean = mean(x), sd = sd(x))
> yfit <- yfit * diff(h$mids[1:2] * length(x))
> lines(xfit, yfit, col = "blue", lwd  = 2)
> box()

如果數(shù)據(jù)有許多結(jié)(相同的值),rug(jitter(mtcars$mpag, amount = 0.01)),向每個(gè)數(shù)據(jù)點(diǎn)添加一個(gè)小的隨機(jī)值(一個(gè)±amount之間的均勻分布隨機(jī)數(shù)),以避免重疊的點(diǎn)產(chǎn)生影響。

6.4 核密度圖

核密度估計(jì)是用于估計(jì)隨機(jī)變量概率密度函數(shù)的一種非參數(shù)方法。
plot(density(x))
其中的x是一個(gè)數(shù)值型向量。plot()函數(shù)會(huì)創(chuàng)建一幅新的圖形,所以要向一幅已經(jīng)存在的圖形上疊加一條密度曲線(xiàn),可以使用lines()函數(shù)(見(jiàn)上文)。

> par(mfrow = c(2, 1))
> d <- density(mtcars$mpg)
> plot(d)
> plot(d, main = "Kernel Dendity of Miles Per Gallon")
> polygon(d, col = "red", border = "blue") #polygon()函數(shù)根據(jù)定點(diǎn)的x和y坐標(biāo)繪制多邊形
> rug(mtcars$mpg, col = "brown")

核密度圖可用于比較組間差異,使用sm包中的sm.density.compare()函數(shù)可向圖形疊加兩組或更多的核密度圖:sm.density.compare(x, factor)
其中的x是一個(gè)數(shù)值型向量,factor是一個(gè)分組變量。

> library(sm)
> attach(mtcars)
#創(chuàng)建分組因子
> cyl.f <- factor(cyl, levels = c(4, 6, 8), labels = c("4 cylinder", "6 cylinder", "8 cylinder"))
#繪制密度圖
> sm.density.compare(mpg, cyl, xlab = "Miles Per Gallon")
> title(main = "MPG Distribution by Car Cylinders")
#通過(guò)鼠標(biāo)單擊添加圖例
> colfill <- c(2:(1 + length(levels(cyl.f))))
> legend(locator(1), levels(cyl.f), fill = colfill)
> detach(mtcars)

6.5 箱線(xiàn)圖

箱線(xiàn)圖(盒須圖)是一項(xiàng)用來(lái)可視化分布和組間差異的絕佳圖形手段(更常用)。
通過(guò)繪制連續(xù)型變量的五數(shù)總括,即最小值、下四分位數(shù)(第25百分位數(shù))、中位數(shù)(第50百分位數(shù))、上四分位數(shù)(第75百分位數(shù))以及最大值,描述了連續(xù)型變量的分布。箱線(xiàn)圖能夠顯示出可能為離群點(diǎn)(范圍±1.5*IQR以外的值,IQR表示四分位距,即上四分位數(shù)與下四分位數(shù)的差值)的觀測(cè)。

> boxplot(mtcars$mpg, main = "Box plot", ylab = "Miles per Gallon")
#輸出用于構(gòu)建圖形的統(tǒng)計(jì)量
> boxplot.stats(mtcars$mpg)

6.5.1 使用并列箱線(xiàn)圖進(jìn)行跨組比較

箱線(xiàn)圖可以展示單個(gè)變量或分組變量。使用格式為:
boxplot(formula, data = dataframe)
其中的formula是一個(gè)公式,dataframe代表提供數(shù)據(jù)的數(shù)據(jù)框或列表。
一個(gè)實(shí)例公式為y ~ A,這將為類(lèi)別型變量A的每個(gè)值并列地生成數(shù)值型變量y的箱線(xiàn)圖。公式y(tǒng) ~ A*B則將為類(lèi)別型變量A和B所有水平的兩兩組合生成數(shù)值型變量y的箱線(xiàn)圖。
添加參數(shù)varwidth = TRUE將使箱線(xiàn)圖的寬度與其樣本大小的平方根成正比。參數(shù)horizontal = TRUE可以反轉(zhuǎn)坐標(biāo)軸的方向。

> attach(mtcars)
> boxplot(mpg ~ cyl, data = mtcars, main = "Car Mileage Data", xlab = "Number of Cylinders", ylab = "Miles Per Gallon")
#添加notch = TRUE得到含凹槽的箱線(xiàn)圖。
> boxplot(mpg ~ cyl, data = mtcars, notch = TRUE, col = "red", main = "Car Mileage Data", xlab = "Number of Cylinders", ylab = "Miles Per Gallon")
> detach(mtcars)

兩個(gè)交叉因子的箱線(xiàn)圖:

#創(chuàng)建汽缸數(shù)量的因子
> mtcars$cyl.f <- factor(mtcars$cyl, levels = c(4, 6, 8), labels = c("4", "6", "8"))
#創(chuàng)建變速箱類(lèi)型的因子
> mtcars$am.f <- factor(mtcars$am, levels = c(0, 1), labels = c("anto", "standard"))
> boxplot(mpg ~ am.f * cyl.f, data = mtcars, varwidth = TRUE, col = c("gold", "darkgreen"), main = "MPG Distribution by Auto Type", xlab = "Auto Type", ylab = "Miles Per Gallon")

6.5.2 小提琴圖

箱線(xiàn)圖與核密度圖的結(jié)合,使用vioplot包中的vioplot()函數(shù)繪制。
vioplot(x1, x2, ... , names = , col = )
其中x1, x2, ...表示要繪制的一個(gè)或多個(gè)數(shù)值向量(將為每個(gè)向量繪制一幅小提琴圖),參數(shù)names是小提琴圖中標(biāo)簽的字符向量,而col是一個(gè)為每幅小提琴圖指定顏色的向量。

> library(vioplot)
> x1 <- mtcars$mpg[mtcars$cyl == 4]
> x2 <- mtcars$mpg[mtcars$cyl == 6]
> x3 <- mtcars$mpg[mtcars$cyl == 8]
> vioplot(x1, x2, x3, names = c("4 cyl", "6 cyl", "8 cyl"), col = "gold")
> title("Violin Plots of Miles Per Gallon", ylab = "Miles Per Gallon", xlab = "Number of Cylinders")

6.6 點(diǎn)圖

點(diǎn)圖繪制變量中的所有值,提供了一種在水平刻度上繪制大量有標(biāo)簽值的方法。
dotchart(x, labels = )
其中的x是一個(gè)數(shù)值向量,而labels則是由每個(gè)點(diǎn)的標(biāo)簽組成的向量??梢酝ㄟ^(guò)添加參數(shù)groups來(lái)選定一個(gè)因子,用以指定x中元素的分組方式。如果這樣做,gcolor可以控制不同組標(biāo)簽的顏色,cex可以控制標(biāo)簽的大小。

> dotchart(mtcars$mpg, labels = row.names(mtcars), cex = .7, main = "Gas Mileage for Car Models", xlab = "Miles Per Gallon")
#分組、排序、著色后的點(diǎn)圖
> x <- mtcars[order(mtcars$mpg), ]
> x$cyl <- factor(x$cyl)
> x$color[x$cyl == 4] <- "red"
> x$color[x$cyl == 6] <- "blue"
> x$color[x$cyl == 8] <- "darkgreen"
> dotchart(x$mpg, labels = row.names(x), cex = .7, groups = x$cyl)
> dotchart(x$mpg, labels = row.names(x), cex = .7, groups = x$cyl, gcolor = "black", color = x$color, pch = 19, main = "Gas Mileage for Car Models\n grouped by cylinder", xlab = "Miles Per Gallon")

點(diǎn)圖有許多變種,Hmisc包提供了一個(gè)帶有許多附加功能的點(diǎn)圖函數(shù)dotchart2。

第7章 基本統(tǒng)計(jì)分析

7.1 描述性統(tǒng)計(jì)分析

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容