Home > Blockchain >  Problem with radarchart using fmbs library
Problem with radarchart using fmbs library

Time:11-03

I'm helping a friend making figures to her publication. She need radar charts, send me the data. I'm using fmsb library in R, but have some problem. The data is the following (some modified, because it's unpublished :) )

consequences timeline personal control treatment control identity concern comprehensibility emotions
Min 0 0 0 0 0 0 0 0
Max 10 10 10 10 10 10 10 10
Mean 7.74 6.14 5.2 2.82 7.12 7.18 2.44 7.26

The code:

radarchart(chaos_story2,
  axistype = 4, 
  axislabcol = "black",
  seg = 5, 
  caxislabels= c(0,2,4,6,8,10), 
  cglcol="black")

enter image description here

The problem, that it seems the radarchart use the 1-mean values to plot the means, not the actual values. How I can solve this?

Thank you in advance

CodePudding user response:

The issue is that the min and max rows are in the wrong order. According to the docs ?radarchart:

If maxmin is TRUE, 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.

Fixing the order gives the desired result.

Note: There is probably an issue with your example data, i.e. I dropped the consequences column as it contained the rownames.

library(fmsb)

# Max has to be first row, min the second
chaos_story2 <- chaos_story2[c(2, 1, 3), ]

radarchart(chaos_story2,
           axistype = 4, 
           axislabcol = "black",
           seg = 5, 
           caxislabels= c(0,2,4,6,8,10), 
           cglcol="black")

DATA

chaos_story2 <- data.frame(
       consequences = c("Min", "Max", "Mean"),
           timeline = c(0, 10, 7.74),
   personal.control = c(0, 10, 6.14),
          treatment = c(0, 10, 5.2),
            control = c(0, 10, 2.82),
           identity = c(0, 10, 7.12),
            concern = c(0, 10, 7.18),
  comprehensibility = c(0, 10, 2.44),
           emotions = c(0, 10, 7.26)
)

rownames(chaos_story2) <- chaos_story2$consequences
chaos_story2$consequences <- NULL
``
  • Related