I was trying to make a radarchart
using fmsb
but I'm having some trouble with my script.
If anyone can help I will be really appreciated.
my radarchart sequence must be between (0,2) and by 0.2. But when I try it the graph it is out of bounds. my script:
library("fmsb")
data:
df <- data.frame("hours" = 0:23,
"max_value" = 2,"min_value" = 0,"CallsProportion" = (c(1.583333333
,1.291666667,1.166666667,1,0.041666667,0.833333333,0.625
,0.791666667,0.75,0.458333333,0.833333333,0.625,0.708333333,0.458333333,0.291666667,0.416666667,0.625,0.458333333,1.208333333,2.375,2.166666667,2.208333333,1.625,1.541666667)))
radarchart(df, axistype = 1,
caxislabels = seq(0,2,0.2),
cglcol = "grey",
vlcex = 0.8, cglty = 1,
cglwd = 0.5,axislabcol = "grey",
pcol = "black",plwd = 1.8, plty = 1)
This is a data format problem. Function fmsb::radarchart
needs an object of class "data.frame"
as first argument, a "matrix"
won't do it. From help("radarchart")
:
The data frame to be used to draw
radarchart
. Ifmaxmin
isTRUE
, this must include maximum values as row 1 and minimum values as row 2 for each variables, and actual data should be given as row 3 and lower rows. The number of columns (variables) must be more than 2.
Note that maxmin = TRUE
is the default setting.
So follow these steps.
df
, column hours
. In this case there is just one vector to plot, vector CallsProportion
.
r <- range(df$CallsProportion)
m <- matrix(r[2:1], nrow = 2, ncol = nrow(df))
df2 <- rbind.data.frame(m, df$CallsProportion)
names(df2) <- df$hours
radarchart(df2, axistype = 1,
caxislabels = seq(0, 2, 0.2),
cglcol = "grey",
vlcex = 0.8, cglty = 1,
cglwd = 0.5, axislabcol = "grey",
pcol = "black", plwd = 1.8, plty = 1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.