Spider Chart by R


#1

I am going to create a spider chart using following code, but error message occurred, can anyone help me to solve the problem? Thank you!

when run

mtcars %>% rownames_to_column(var="group") %>%
mutate_each(funs(rescale), ~group) %>%
tail(4) %>% select(1:10) ->mtcars_radar

Error message displayed

`mutate_each()` is deprecated.
Use `mutate_all()`, `mutate_at()` or `mutate_if()` instead.
To map `funs` over a selection of variables, use `mutate_at()`
Error: `~group` must evaluate to column positions or names, not formula
#Here is the entire program
######################################################################
library(ggradar)
suppressPackageStartupMessages(library(dplyr))
library(scales)

library(tibble)
data(mtcars)
mtcars %>% as_data_frame() %>% rownames_to_column(var="group") %>%
  mutate_each(funs(rescale), ~group) %>%
  tail(4) %>% select(1:10) ->mtcars_radar

mtcars %>% rownames_to_column(var="group") %>%
  mutate_each(funs(rescale), ~group) %>%
  tail(4) %>% select(1:10) ->mtcars_radar

##ggradar make spider chart
ggradar(mtcars_radar)

#2

Unfortunately, I had some problems getting ggradar installed (requires a specific font, for instance), but I think this code should work to scale the numeric columns of mtcars to the range 0-1.

library(ggradar) # I couldn't get it to install :-(
suppressPackageStartupMessages(library(dplyr))
library(scales)
library(tidyverse)
data(mtcars)
  
mtcars %>% 
  as_data_frame() %>% 
  rownames_to_column(var="group") %>%
  mutate_if(is_numeric, funs(rescale)) %>%
  tail(4) %>% select(1:10) -> mtcars_radar
  
  # Fingers crossed?
  ggradar(mtcars_radar)

#3

Thank you! It works!
but seems need to changed is_numeric to is.numeric


#4

Here is for installing ggradar
devtools::install_github("ricardo-bion/ggradar", dependencies=TRUE)