Suggestions on how to visualize survey data

I have some survey data, where the first question is something like, "rate how you are feeling on a scale of 1 - 5". The next group of questions are something like, "do you smoke?" or "how much exercise do you get per day: 0, 15, 30, 45, 60, 60+?"

I'm looking for a way to visualize this data, where each question is compared to how the the surveyor is feeling. Any suggestions? I came across a correlation matrix, but it seems I can't have how you are feeling scale on the x-axis and the questions on the y-axis.

feeling_scale,  smokes,  exercise_frequency
5,              N,       15
3,              Y,       60
5,              Y,        0

• Yes, I'm sure you can. If you made a reproducible example it might be possible to answer your question. Aug 21, 2012 at 13:31
• @Aaron thanks! That's the kind of stuff I was looking for. Perhaps my questions wasn't clear
Aug 21, 2012 at 13:46
• The downvotes are perhaps because 1) there's not sample data, and 2) you say you can't use a correlation matrix, but don't explain why you don't think so. It would have been more polite for the downvoters to explain why and give you a chance to fix it before downvoting. It's not necessarily a bad question; it just needs a little improvement. Aug 21, 2012 at 13:49
• Thanks, Aaron. Valid points. I was trying to use corrplot, btw. I just couldn't figure it out and assumed it wasn't possible. Also, all the examples I saw had their x- and y-axis labels the same.
Aug 21, 2012 at 13:50
• More suggestions here: stats.stackexchange.com/q/3921/3601 and here: stats.stackexchange.com/q/25109/3601; I especially like the centered count one. (This comment was left previously but seems to have been lost in the migration; it's what the thanks above was for.) Aug 23, 2012 at 19:51

Try the lattice package and maybe box-and-whisker plots.

# Make up some data
set.seed(1)
test = data.frame(feeling_scale = sample(1:5, 50, replace=TRUE),
smokes = sample(c("Y", "N"), 50, replace=TRUE),
exercise_frequency = sample(seq(0, 60, 15),
50, replace = TRUE))
library(lattice)
bwplot(exercise_frequency ~ feeling_scale | smokes, test)


I would also think that a basic barchart would be fine for this type of data.

barchart(xtabs(feeling_scale ~ exercise_frequency + smokes, test),
stack=FALSE, horizontal=FALSE, auto.key=list(space = "right"))


A third option I can think of is the bubble plot, but I'll leave it up to you to decide on how to scale the circles appropriately. It also requires that you first get the frequencies of the different combinations of exercise_frequency and feeling_scale.

test2 = data.frame(with(test,
table(feeling_scale,
exercise_frequency, smokes)))
par(mfrow = c(1, 2))
lapply(split(test2, test2$smokes), function(x) symbols(x$feeling_scale, x$exercise_frequency, circles = x$Freq, inches=1/4))


I am thinking that you could simply summarize the data in a contingency table. The columns could be the question numbers and the rows the specific answers. The ij$^t$$^h$ cell would contain the number of responses to question i with response j.

Could you just use a pie chart? Each category would be one piece of the pie and it's size would be the proportion it represents of the total.

• I would then have to show a pie chart at productivity=1, productivity=2, ..., productivity=5 for each question, right? I'm looking for less.
par(mar=c(1.1,4.1,4.1,2.1))
boxplot(test$exercise_frequency~as.factor(test$feeling_scale), main="Overall")
boxplot(test$exercise_frequency[test$smokes == "Y"]~as.factor(test$feeling_scale[test$smokes == "Y"]),
boxplot(test$exercise_frequency[test$smokes == "N"]~as.factor(test$feeling_scale[test$smokes == "N"]),