Tuesday, January 15, 2013

Creating an easy pie chart from data vectors

R script

# Pie charts can be a memorable way of representing information.

# There are a number of online examples showing how to create pie charts in R.

# For example: http://www.statmethods.net/graphs/pie.html

# Imagine you have survey response data from 100 respondents and your survey answers range from A do D.

# This will draw 100 draws from the LETTERS vector between A and D
response = LETTERS[ceiling(runif(100)^2*4)]

# You would like to now see the pie chart of results you can simply tabulate.

# We can see that about half the results are A followed by B then C then D.

# Note, that without including percentages it is often difficult to identify the differences in the individual sizes of each slice.

No comments:

Post a Comment