||
在R软件(或Rstudio)中,使用以下方法安装。
方法1:from github
install.packages("devtools")
devtools::install_github("PhDMeiwp/ggradar2", dependencies = TRUE)
方法2:from gitee (国内可用)
install.packages("git2r")
install.packages("remotes")
library(git2r)
library(remotes)
remotes::install_git("https://gitee.com/meiweiping/ggradar2.git")
方法3:先从Github或gitee下载 .Zip 或 .tar.gz 文件到电脑本地,然后安装
devtools::install_local("E:/R/ggradar2/ggradar2-master.zip") # zip文件
devtools::install_local("E:/R/ggradar2/ggradar2_0.3.tar.gz") # tar.gz文件
注意要将上述路径改成你自己的路径。
二、使用ggradar2
先加载 ggradar2 函数包
library(ggradar2)
案例1 (one group)如下:
df <- data.frame(
NAME = 'G1',
A = 0.4, B = 0.8, C = 0.5, D = 0.8, E = 0.5 )
ggradar2(df)
案例2 (grid line setting)如下:
df <- data.frame(
NAME = 'G1',
A = 123, B = 65, C = 157, D = 181, E = 99 )
ggradar2(df,
# radar values
values.radar = c("0", "50", "100", "150", "", "200"),
# centre position
centre.y = 0,
# grid lines
gridline.n2.colour = "blue",
gridline.n4.colour = "blue",
# grid labels
gridline.label.offset.y = 0,
# axis labels
axis.label.offset = 1.2
)
案例 3 (multiple groups)如下:
df <- data.frame(
NAME = c('G1', 'G2', 'G3'),
A = c(0.2, 0.4, 0.5), B = c(0.3, 0.6, 0.3),
C = c(0.7, 0.3, 0.5), D = c(0.4, 0.8, 0.2), E = c(0.5, 0.6, 0.3) )
ggradar2(df)
案例 4 (fill setting) 如下:
df <- data.frame(
NAME = c('G1', 'G2', 'G3'),
A = c(2, 4, 5), B = c(3, 6, 3),
C = c(7, 3, 5), D = c(4, 8, 2), E = c(5, 6, 3) )
ggradar2(df,
values.radar = c("0", "2", "4", "6", "8", "10"),
grid.line.width = 0.3,
# group parameters
group.line.width = 0.5,
group.point.size = 2,
group.colours = c("red","orange","green"),
fill = TRUE,
fill.alpha = 0.2,
axis.label.offset = 1.15,
axis.label.size = 4,
background.circle.colour = "white" )
案例 5 (default ggradar plot) 如下:
df <- data.frame(
NAME = 'G1',
A = 0.4, B = 0.8, C = 0.5, D = 0.8, E = 0.5 )
ggradar2(df,
# radar values
values.radar = c("0%", "50%", "", "", "", "100%"),
# grid labels
grid.label.color = "#000000",
grid.label.size = 6,
gridline.label.offset.x = -0.1,
gridline.n2.colour = "#007A87",
# group
group.point.size = 6
)
三、重要说明ggradar2函数包的版权,归ggradar函数包原作者 Ricardo Bion 所有,本人只是众多的贡献者之一。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-28 03:25
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社