R语言:实现雷达图的绘制
如何安装R包参考这篇文章:https://www.cnblogs.com/zzj420133722/p/12677399.html
实现代码:
install.packages("knitr") install.packages("isoband") install.packages("withr") install.packages("tibble") install.packages("pkgbuild") library(rJava) library(devtools) library(usethis) devtools::install_local("D://ChromeDownload/ggradar-master.zip") rm(list=ls()) gc() library(ggradar) mydata<-matrix(runif(40,0,1),5,8) #以上构造了一个值区间为0~1,个数为40的5行8列随机数矩阵。 rownames(mydata) <- LETTERS[1:5] #以上使用前五个大写字母为矩阵行命名 colnames(mydata) <- c("Apple","Google","Facebook","Amozon","Tencent","Alibaba","Baidu","Twitter") #使用以上文本向量为矩阵列命名 mynewdata<-data.frame(mydata) # 为数据框增加一列文本字段 Name<-c("USA","CHN","UK","RUS","JP") mynewdata<-data.frame(Name,mynewdata) ggradar(mynewdata) library(knitr) kable(mynewdata,format="markdown")
运行效果: