radarchart package expects data to be in a format whereby each row corresponds to an axis on the chart (or a
Label) and each column is a set of scores. An example is the built in data set,
In many cases your data will have a column for each axis, and each row is a set of observations. In the
skills example we might build up a spreadsheet where each row is a person and each column a skill.
In order to use this data set with
radarchart we need to rotate it. This can be done with packages such as
library(tidyr) skillsByLabel <- gather(skillsByName, key=Label, value=Score, -Name) %>% spread(key=Name, value=Score) skillsByLabel
If you don't want to have a dependency on
tidyr then you can do the same thing using a few lines of base
skillsByLabel <- as.data.frame(t(skillsByName[,-1])) names(skillsByLabel) <- skillsByName$Name skillsByLabel <- cbind(Label=row.names(skillsByLabel), skillsByLabel) row.names(skillsByLabel) <- NULL
This rotated data set is now ready for use with
chartJSRadar(scores = skillsByLabel, maxScale = 10)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.