Spider plots in R

This is mainly a note for myself

Lets create some data

dat = data.frame(E1=rnorm(10,2.5), E2=rnorm(10,1.5), E3=rnorm(10,3))

dat$Activity=c(1,1,1,2,2,2,3,3,3,3)

I want to draw spider plot using a mean values of each column grouped by Activity

require(plyr)

cdata <- ddply(dat, c("Activity"), summarise, E1 = mean(E1), E2=mean(E2), E3=mean(E3)

radar char requires Max, Min and data to be drawn. Above we transformed data so that we have mean values for E1, E2, and E3 in one row per condition. Next, we add a row that contains minimum values for radarchart command:

cdata=rbind(c(0,0,0), cdata)

Next, we add row containing maximum values for radarchart

cdata=rbind(c(5,5,5), cdata)

We need names Max, Min so that radarchar finds those (it might be that the order would be enough but I did not test).

rownames(cdata) = c("Max", "Min", "A", "B", "C")

Finally, the spider chart.

require(fmsb)

radarchart(cdata[c("E1", "E2", "E3")])


cdata looks like

    Activity       E1       E2       E3
Max        5 5.000000 5.000000 5.000000
Min        0 0.000000 0.000000 0.000000
A          1 2.057835 1.735599 3.304232
B          2 2.226611 1.471724 3.370966
C          3 3.206408 1.572105 2.398983

And spider plot

Published by lankoski

Petri Lankoski, D.Arts, is a Associate Professor in Game Studies at the school of Communication, Media and IT at the Södertörn University, Sweden. His research focuses on game design, game characters, role-playing, and playing experience. Petri has been concentrating on single-player video games but researched also (multi-player) pnp and live-action role-playing games. This blog focuses on his research on games and related things.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: