日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

R语言与数据的图表展示(part1)--不知道起啥名,反正就是初步认识一下

發布時間:2023/12/19 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 R语言与数据的图表展示(part1)--不知道起啥名,反正就是初步认识一下 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考書目:《統計學》-賈俊平;《統計學:從數據到結論》-吳喜之;
理論部分:數據的圖表展示


  • 條形圖
data01 <- c('紅茶', '咖啡', '胡蘿卜汁', '咖啡', '咖啡', '紅茶') data02 <- data.frame(x = c(4,5,2), y = c('白兔', '黑兔', '黃兔'))par(mfrow=c(1, 2)) barplot(table(data01), main = "箱線圖") barplot(data02$x, names.arg = data02$y, main = "箱線圖")

圖像:

  • 餅圖
data01 <- c('紅茶', '咖啡', '胡蘿卜汁', '咖啡', '咖啡', '紅茶') pie(table(data01), paste(names(table(data01)), " ", round(table(data01)/sum(table(data01)), 4)*100, "%", sep = ""),main = "餅圖")

圖像:

  • 直方圖
set.seed(1234) data03 <- rnorm(100, 0, 1) hist(data03, main = "直方圖", xlim = c(-4, 4), ylim = c(0, 30),col = palette())

圖像:

關于代碼中用到的顏色板:

> palette() [1] "black" "red" "green3" "blue" "cyan" "magenta" "yellow" [8] "gray
  • 莖葉圖
set.seed(1234) (data04 <- round(runif(30, 0, 50))) stem(data04)

控制臺輸出:

> (data04 <- round(runif(30, 0, 50)))[1] 6 31 30 31 43 32 0 12 33 26 35 27 14 46 15 42 14 13 9 12 16 15 8 2 11 [26] 41 26 46 42 2 > stem(data04)The decimal point is 1 digit(s) to the right of the |0 | 0220 | 6891 | 1223441 | 5562 | 2 | 6673 | 011233 | 54 | 12234 | 66
  • 箱線圖
data(iris) boxplot(Petal.Width ~ Species, iris, main = "箱線圖")

圖像:

  • 線圖
x <- c(1:10) y1 <- x*3 + rnorm(10, 0, 1) plot(x, y1, type = 'o', main = "線圖", ylim = c(-2, 32),ylab = "y") y2 <- x -1 + rnorm(10, 0, 1) lines(x, y2, type = 'o', col = 'red')

圖像:

  • 散點圖
x <- c(1:10) y1 <- x*2 + rnorm(10, 1, 2) plot(x, y1, main = "散點圖", ylab = "y")

圖像:

  • 矩陣散點圖
pairs(iris[,c(1:3)])

圖像:

  • 氣泡圖
x <- iris[c(1:30),1] y <- iris[c(1:30),2] z <- iris[c(1:30),3]plot(x, y, pch = 1, cex = z, main = '氣泡圖')

圖像:

  • 雷達圖
library(fmsb) df <- data.frame(x = c(10, 5 ,1), y = c(6, 3, 2), z = c(11, 20, 10), t = c(5:7))df_max <- apply(df, 2, max) df_min <- apply(df, 2, min) new_df <- data.frame(rbind(df_max, df_min, df)) radarchart(df = new_df, seg =5, plty = c(1:5), vlcex = 1, plwd = 2)

圖像:

備注:關于雷達圖的參數使用可見Blog:雷達圖的實現

總結

以上是生活随笔為你收集整理的R语言与数据的图表展示(part1)--不知道起啥名,反正就是初步认识一下的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。