Creating a radar plot for multivariate data

22 views
Skip to first unread message

Raveen Rathnasinghe

unread,
Jul 27, 2015, 1:06:53 PM7/27/15
to ggplot2
Dear all,

I am a newbie to R and I am still learning my way around. I am currently attempting to plot multivariate data ( 18 rows and 96 columns with numeric normalized data) using a Radar/Radial plot via ggplot. I have attached a image of the layout of my data to exemplify how my data looks.







 I used the following modified code (highlighted in yellow) which I adapted from a similar yet simplified example and it doesn't seem to work. Any help or recommendations are welcome! Thank you in advance

Regards,
Raveen


#Data framing
library("fmsb")
dd<-data.frame(
  clust = 1:18,
  v1 <- c(-0.10,-1.64,-0.85,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-1.18,-0.18,0.17,-0.77,0.00),
  v2 <- c(-0.41,-0.60,-1.14,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-2.04,-0.12,-0.07,-0.77,-0.04),
  v3 <- c(-0.31,-0.35,-0.94,0.72,0.00,-0.11,-0.02,0.00,0.00,0.00,-0.15,0.15,-0.31,0.62,0.04,-0.06,-0.77,-0.15),
  v4 <- c(0.18,0.08,0.36,-0.28,0.00,0.17,0.07,0.00,0.00,0.00,-0.15,0.15,0.59,-0.55,0.02,0.00,0.47,-0.15),
  v5 <- c(-0.08,-0.35,-1.10,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-2.04,-0.25,-0.03,-0.77,-0.22),
  v6 <- c(-0.57,-0.35,-0.29,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-0.61,0.06,0.02,-0.77,-0.10),
  v7 <- c(0.16,0.08,-0.51,-0.28,0.00,-0.86,-0.02,0.00,0.00,0.01,-0.15,-0.12,-1.07,-0.26,0.19,-0.05,-0.35,0.11),
  v8 <- c(-0.35,-0.11,-0.58,-0.28,0.00,0.49,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-1.60,-0.10,0.09,-0.03,0.17),
  v9 <- c(-0.18,0.28,-0.18,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,0.52,0.24,-0.19,-0.68,0.07),
  v10 <- c(0.50,0.52,0.74,-0.28,0.00,0.63,0.08,0.00,0.00,0.00,0.57,0.63,0.70,0.12,-0.22,0.03,0.67,0.12),
  v11 <- c(-0.18,-0.89,-0.74,1.39,0.97,-0.51,0.00,0.20,0.28,0.57,-0.59,-0.35,-0.51,-0.62,0.48,0.05,-0.88,0.35),
  v12 <- c(0.06,0.40,-0.08,1.34,2.34,-0.29,0.75,0.11,0.48,0.58,0.02,-0.13,-0.10,-0.13,1.16,0.13,0.19,0.97),
  v13 <- c(-0.31,0.66,-0.53,1.14,0.00,-1.34,0.37,0.00,0.00,0.00,-0.15,-0.33,-0.66,-0.52,0.68,0.37,-0.35,0.43),
  v14 <- c(0.73,0.68,-0.35,1.77,1.79,-0.54,0.75,0.31,0.74,0.86,0.36,0.24,-0.13,-0.28,0.58,-0.27,-0.34,0.31),
  v15 <- c(-0.03,0.36,-0.19,-0.28,0.00,-1.34,0.17,0.00,0.00,0.00,-0.15,-0.24,-0.61,0.00,0.51,0.19,-0.68,0.28),
  v16 <- c(-0.32,-0.89,-1.39,0.91,0.54,-0.51,0.02,0.20,0.28,0.57,-0.59,-0.35,-0.75,-0.68,0.21,0.49,-0.28,-0.09),
  v17 <- c(0.41,0.48,-0.53,0.94,1.68,-0.62,0.69,0.48,0.10,0.16,-0.15,0.04,-0.04,-0.18,0.49,-0.24,-0.77,0.03),
  v18 <- c(0.37,0.61,-0.30,1.45,2.30,0.14,1.06,0.23,0.93,0.45,-0.15,-0.02,0.32,0.06,1.18,0.43,0.24,0.77),
  v19 <- c(-0.45,0.32,-0.61,1.10,0.49,-0.52,0.44,0.00,0.32,0.54,-0.37,-0.21,0.48,-0.32,1.19,0.59,-1.02,-0.08),
  v20 <- c(0.55,0.42,-0.60,1.20,1.15,-0.86,0.77,0.02,0.38,0.76,0.05,0.20,-0.14,-0.10,0.11,-0.39,-0.32,0.41),
  v21 <- c(-0.35,-0.60,-0.61,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-0.93,-0.25,0.22,0.30,-0.11,0.29),
  v22 <- c(-0.01,0.36,-0.64,-0.28,0.00,-1.15,-0.01,0.00,0.00,0.27,-0.15,-0.18,-1.07,-1.33,0.12,-0.11,-0.77,-0.06),
  v23 <- c(-0.04,0.38,-1.02,0.68,0.57,-0.54,0.77,-0.06,0.13,0.25,-0.12,-0.56,-0.42,-0.53,0.26,-0.16,-0.40,0.05),
  v24 <- c(0.04,0.27,-0.81,1.61,1.50,-0.51,0.45,0.20,0.28,0.57,-0.59,-0.35,-0.75,-0.35,0.46,0.39,-0.88,0.48),
  v25 <- c(0.35,0.33,-0.62,0.38,1.10,-0.54,0.69,0.24,0.35,0.25,-0.14,-0.59,-0.91,-0.28,0.00,0.27,-0.41,0.25),
  v26 <- c(0.02,0.50,-0.92,0.31,1.16,-0.51,0.40,0.20,0.28,0.57,-0.59,-0.35,-0.56,-0.02,0.64,0.58,-0.13,0.47),
  v27 <- c(-0.15,-0.52,-0.50,1.96,0.54,-0.51,0.93,1.02,0.28,0.57,-0.59,-0.35,1.26,0.08,1.02,0.76,-0.58,0.42),
  v28 <- c(-0.07,-0.09,-0.74,0.99,0.54,-0.51,0.15,0.20,0.28,0.57,-0.59,-0.19,-0.55,-1.05,0.91,-0.11,-0.41,0.06),
  v29 <- c(1.05,0.84,-0.17,1.15,2.19,1.17,0.78,0.89,0.95,0.68,1.56,0.87,0.30,0.04,0.42,0.84,0.08,0.14),
  v30 <- c(0.03,0.27,-0.21,1.31,1.09,-0.51,0.58,0.20,0.28,0.57,-0.59,-0.24,-0.64,-0.29,1.11,0.62,-0.18,0.26),
  v31 <- c(0.03,0.41,-0.50,1.41,0.54,-0.51,0.72,0.20,0.28,0.57,-0.59,-0.30,-0.25,-0.54,1.11,0.11,-0.48,0.38),
  v32 <- c(-0.22,-0.52,-0.47,1.17,0.54,-0.51,0.44,0.20,0.28,0.57,-0.59,-0.11,-0.75,-0.49,0.86,0.45,-0.70,0.13),
  v33 <- c(-0.45,-0.89,-1.39,0.19,0.54,-0.51,0.00,0.20,0.28,0.57,-0.59,-0.35,-0.75,-1.75,-0.18,-0.06,-0.88,-0.11),
  v34 <- c(0.08,-0.26,0.82,1.75,0.97,-0.51,0.00,0.20,0.28,0.57,-0.59,-0.17,-0.44,-0.36,0.98,0.45,-0.88,0.57),
  v35 <- c(0.18,0.31,-0.07,1.37,1.89,0.10,0.89,0.33,0.28,0.57,0.08,-0.19,-0.08,0.45,1.20,1.30,0.08,0.82),
  v36 <- c(-0.18,-0.89,-0.51,0.44,0.54,-0.51,1.40,0.20,0.28,0.57,-0.59,0.12,0.57,-0.24,0.72,1.10,-0.72,-0.37),
  v37 <- c(-0.01,-0.26,-0.91,1.06,1.45,-0.51,0.68,3.35,0.28,0.57,-0.59,-0.21,0.69,2.30,0.12,0.30,1.54,1.79),
  v38 <- c(-0.25,1.94,-0.28,1.82,1.44,-0.51,0.91,0.20,0.28,0.57,-0.59,-0.35,0.40,-0.03,1.20,1.52,-0.13,0.65),
  v39 <- c(0.52,0.93,0.33,1.83,1.61,-0.44,1.02,0.20,0.28,0.57,-0.59,-0.21,0.99,0.22,1.20,1.20,0.15,0.77),
  v40 <- c(0.00,0.06,-0.84,1.25,0.54,-0.51,0.95,0.20,0.28,0.57,-0.59,-0.34,2.31,0.64,0.92,1.47,0.46,0.87),
  v41 <- c(-0.05,-0.89,-0.69,1.25,2.34,-0.51,0.91,0.20,0.28,0.57,-0.59,0.31,0.87,0.28,1.13,1.21,-0.14,-0.36),
  v42 <- c(-0.18,0.31,-1.39,0.98,0.54,-0.51,1.01,0.20,0.28,0.57,-0.59,-0.35,-0.46,-0.59,0.24,0.10,-0.21,0.14),
  v43 <- c(0.16,-0.12,-0.37,1.88,1.26,-0.86,1.14,0.00,0.22,0.54,-0.37,-0.30,0.37,0.27,1.20,0.36,0.19,0.66),
  v44 <- c(0.61,0.76,0.73,2.15,0.00,-1.23,1.08,0.53,0.95,0.46,-0.15,1.19,0.61,0.50,1.19,0.87,0.37,0.55),
  v45 <- c(0.67,0.59,-0.08,1.83,1.56,-0.86,1.35,0.36,0.61,0.53,0.27,-0.14,0.21,-0.25,0.66,0.15,0.01,0.48),
  v46 <- c(0.56,0.29,-0.37,0.72,1.65,-0.83,0.24,0.00,0.43,0.64,-0.13,0.15,-0.91,-0.70,-0.51,-0.07,-0.12,-0.14),
  v47 <- c(1.75,1.18,0.24,1.23,2.88,-0.86,1.99,1.65,1.84,1.49,1.14,-0.18,-0.18,0.26,0.35,-0.27,-0.81,0.62),
  v48 <- c(-0.26,0.94,0.14,1.42,0.00,-1.34,0.87,0.57,0.00,0.00,-0.15,0.18,0.15,-0.23,1.19,1.16,-0.77,0.53),
  v49 <- c(0.09,0.15,-0.77,0.70,1.69,-0.55,-0.05,0.00,0.20,0.53,-0.37,-0.10,-0.22,-0.50,0.08,0.10,-0.27,0.25),
  v50 <- c(0.13,0.44,-0.67,0.89,0.00,-1.34,0.66,0.00,0.00,0.02,-0.15,-0.23,-0.93,-0.31,0.85,0.43,-0.28,0.31),
  v51 <- c(-0.35,0.34,-0.88,-0.28,0.00,-1.34,-0.02,0.00,0.00,0.00,-0.15,-0.45,-1.07,-1.14,0.62,-0.16,-0.77,0.22),
  v52 <- c(-0.19,-0.37,-0.44,1.66,0.59,-0.79,0.97,0.00,0.52,0.53,-0.37,-0.30,1.00,0.46,1.20,1.19,0.24,0.71),
  v53 <- c(0.27,0.30,-0.82,1.29,0.98,-0.86,0.64,0.00,1.28,0.53,-0.37,-0.29,-0.35,-0.03,0.74,-0.01,-0.25,-0.02),
  v54 <- c(-0.12,0.14,-0.62,1.56,1.91,-0.47,0.28,0.11,0.22,0.53,-0.24,-0.22,-0.74,-0.24,0.56,0.15,-0.57,0.18),
  v55 <- c(0.17,0.45,0.28,0.71,0.00,-1.34,0.50,0.00,0.04,0.00,-0.15,-0.30,-1.07,-0.31,0.17,-0.01,0.01,0.10),
  v56 <- c(0.58,0.30,-0.06,1.73,1.54,-0.52,1.52,0.00,0.58,0.53,-0.37,-0.23,0.68,0.32,1.19,0.81,0.03,0.27),
  v57 <- c(0.31,-0.15,-0.96,1.13,1.55,-0.86,0.15,0.00,0.32,0.53,-0.26,-0.30,-0.81,-0.26,0.22,-0.01,-0.73,-0.05),
  v58 <- c(0.50,0.23,0.02,1.51,1.59,-0.83,1.12,0.36,0.47,0.57,0.13,0.06,-0.10,-0.12,0.26,0.21,-0.22,0.25),
  v59 <- c(-0.41,-0.32,-0.44,1.42,1.50,-0.36,0.63,0.00,0.41,0.53,-0.37,-0.30,-0.60,-0.26,1.09,-0.02,-1.02,0.23),
  v60 <- c(0.24,-0.04,-1.06,0.32,0.00,-1.34,0.70,0.00,0.00,0.02,-0.15,-0.33,0.91,-0.01,0.52,0.62,0.01,0.58),
  v61 <- c(0.71,0.89,0.40,2.15,2.22,-0.50,0.83,0.58,0.78,0.82,-0.15,0.33,0.70,0.01,0.85,0.29,0.77,1.11),
  v62 <- c(0.81,0.49,-0.84,1.46,1.38,-0.55,0.60,0.39,0.52,0.63,0.06,0.27,0.54,-0.69,-0.02,0.59,-0.59,-0.01),
  v63 <- c(-0.03,0.18,-0.66,0.46,0.57,-0.54,0.30,0.20,0.13,0.25,-0.14,-0.59,-0.91,-0.67,0.16,0.04,-0.61,-0.04),
  v64 <- c(0.59,0.00,-1.04,1.17,0.54,-0.51,0.59,0.20,0.28,0.57,-0.59,0.19,0.76,-0.26,0.23,0.95,-0.32,0.04),
  v65 <- c(-0.06,0.28,-0.72,-0.28,0.00,-1.34,0.19,0.00,0.00,0.02,-0.15,-0.17,-1.07,-0.96,0.12,-0.19,-0.77,-0.12),
  v66 <- c(0.04,0.45,-0.64,1.04,0.00,-1.34,0.59,0.00,0.00,0.01,-0.15,-0.21,-1.07,-0.89,0.49,-0.18,-0.72,0.28),
  v67 <- c(0.72,0.98,0.94,2.55,1.61,-0.14,0.36,0.16,0.39,0.56,-0.15,0.25,0.22,0.19,0.90,0.90,0.26,0.73),
  v68 <- c(-0.28,0.09,-0.49,1.49,1.24,-0.86,0.21,0.00,0.11,0.53,-0.37,-0.24,-0.49,-0.34,0.82,-0.07,-1.02,0.29),
  v69 <- c(0.10,-0.23,-0.99,1.07,0.83,-0.86,-0.01,0.00,0.06,0.53,-0.37,-0.30,-0.45,-0.37,0.73,-0.15,-1.02,-0.08),
  v70 <- c(0.58,0.35,-0.26,1.12,1.75,-0.26,0.63,0.10,0.64,0.64,0.18,0.27,0.09,-0.41,0.64,0.21,-0.02,0.35),
  v71 <- c(0.16,0.26,-0.88,1.01,0.77,-0.86,0.12,0.00,0.29,0.53,-0.37,-0.30,-0.19,-0.85,0.78,-0.24,-0.99,0.15),
  v72 <- c(0.27,0.36,-0.30,1.21,1.55,-0.64,0.60,0.00,0.35,0.56,-0.15,-0.03,-0.35,-0.08,0.99,0.35,-0.97,0.21),
  v73 <- c(0.81,0.88,-0.25,1.21,2.28,-0.08,1.02,1.15,1.10,1.07,0.96,0.57,0.47,-0.35,0.55,-0.32,-0.13,0.34),
  v74 <- c(0.25,0.98,0.01,0.43,1.93,-1.34,0.57,0.00,0.00,0.00,-0.15,-0.34,0.13,-0.20,1.19,0.79,0.33,0.45),
  v75 <- c(0.11,0.51,-0.59,1.43,0.57,-0.54,0.53,-0.06,0.43,0.25,-0.14,0.37,-0.12,-0.07,1.21,-0.19,-0.15,0.35),
  v76 <- c(-0.11,0.07,-0.77,0.68,0.57,-0.54,0.18,-0.06,0.13,0.25,-0.14,-0.59,-0.91,-0.73,0.97,-0.02,-0.61,0.11),
  v77 <- c(0.48,0.48,0.01,1.55,1.17,-1.34,0.35,0.07,0.20,0.34,-0.15,-0.09,0.67,0.17,0.49,0.31,-0.07,0.68),
  v78 <- c(-0.31,-0.07,-1.04,-0.28,0.00,-1.34,0.44,0.00,0.00,0.00,-0.15,-0.25,-1.07,-1.16,-0.04,-0.42,-0.77,-0.05),
  v79 <- c(-0.07,0.28,-0.81,-0.28,0.00,-1.34,0.56,0.00,0.00,0.00,-0.15,-0.38,0.51,-0.35,0.14,0.87,-0.77,0.22),
  v80 <- c(0.18,0.39,0.52,1.71,0.00,-1.34,0.27,0.94,1.47,0.20,-0.15,0.09,0.73,0.15,0.31,0.16,-0.77,0.12),
  v81 <- c(0.88,0.86,-0.16,1.42,1.90,-0.54,0.84,1.02,0.98,0.97,0.78,0.22,0.22,-0.42,0.34,0.23,0.02,0.42),
  v82 <- c(0.50,0.37,-0.06,0.29,1.88,-0.54,0.29,0.45,0.34,0.49,0.16,-0.09,0.18,-0.72,0.31,-0.02,-0.48,0.25),
  v83 <- c(0.30,0.60,-0.49,0.81,0.57,-0.54,0.53,0.48,0.45,0.62,0.25,0.02,-0.17,-0.65,0.05,0.41,-0.45,0.51),
  v84 <- c(-0.05,-0.12,-0.87,1.57,0.54,-0.86,1.02,0.00,0.06,0.53,-0.37,-0.30,0.28,0.35,1.20,0.98,-0.73,0.33),
  v85 <- c(-0.28,-0.89,-1.31,0.91,0.54,-0.44,0.30,0.20,0.28,0.57,-0.59,-0.35,0.76,-0.19,0.47,-0.15,-0.81,0.18),
  v86 <- c(-0.39,0.02,-0.36,0.96,0.57,-0.54,0.32,0.20,0.13,0.25,-0.14,-0.41,-0.70,-0.47,1.07,0.16,-0.61,0.03),
  v87 <- c(-0.03,0.32,-0.75,0.28,0.57,-0.54,0.46,-0.06,0.13,0.32,-0.14,-0.28,0.44,-0.47,0.21,-0.19,-0.61,0.26),
  v88 <- c(-0.05,0.06,-0.83,0.38,0.57,-0.54,0.30,-0.06,0.13,0.25,-0.12,-0.59,-0.07,-0.73,0.13,-0.26,-0.52,-0.01),
  v89 <- c(-0.52,0.15,-0.13,1.34,0.00,-1.34,0.40,0.00,0.00,0.00,-0.15,-0.27,0.73,-0.47,0.92,0.35,-0.77,0.16),
  v90 <- c(0.41,0.44,-0.51,1.59,1.79,-0.54,0.18,0.35,0.37,0.56,0.24,-0.06,-0.10,-0.38,0.43,-0.20,-0.29,0.18),
  v91 <- c(0.44,0.56,-0.20,1.46,1.96,-0.54,0.91,0.69,0.13,0.25,-0.07,-0.59,0.34,0.63,0.80,0.14,-0.61,0.49),
  v92 <- c(0.09,0.04,-0.20,1.35,0.82,-0.54,0.51,0.26,0.13,0.25,-0.14,-0.45,1.66,0.00,0.63,0.45,-0.61,0.13),
  v93 <- c(0.13,0.41,-0.72,0.41,0.57,-0.54,0.49,0.33,0.34,0.42,-0.14,-0.16,-0.08,-0.38,0.38,-0.16,-0.11,0.31),
  v94 <- c(-0.35,0.08,-0.66,0.68,0.57,-0.54,0.36,-0.06,0.13,0.25,-0.14,-0.59,0.37,-0.52,1.17,0.28,-0.52,-0.05),
  v95 <- c(-0.08,0.05,0.71,1.61,0.00,-1.34,0.66,0.00,0.00,0.00,-0.15,-0.32,-0.46,-0.52,0.70,0.00,0.18,0.82),
  v96 <- c(-0.01,-0.89,-1.14,1.61,0.54,-0.51,0.66,0.20,0.28,0.57,-0.59,0.02,1.74,1.06,0.78,0.54,0.15,0.47)
)

#plots

par(mar=c(1,2,2,1))
layout(matrix(1:18, ncol=2))
lapply(1:18, function(i){radarchart(rbind(rep(1,6), rep(0,6), dd[i, -1]))})


Reply all
Reply to author
Forward
0 new messages