Workshop 4
Data visualisation
1
Workshop 4 Data visualisation 2 Learning Objectives By following - - PowerPoint PPT Presentation
1 Workshop 4 Data visualisation 2 Learning Objectives By following the slides and applying the techniques to select examples from the workbook the successful student will be able to: explain what is important in choosing a figure
1
By following the slides and applying the techniques to select examples from the workbook the successful student will be able to:
three explanatory variables which show the data, the main statistical model and the results of any post-hoc testing as appropriate.
2
(without distortion)
the results
3
– Response variable almost always on the vertical axis – Explanatory variables: horizontal axis, colour, shape, size,
4
David McCandless http://www.informationisbeautiful.net/ Hans Rosling’s Gapminder
5
table
Wickham, H. (2014), “Tidy Data,” Journal of Statistical Software, 59, available at http://www.jstatsoft.org/article/view/v059i10 “tidy datasets are all alike but every messy dataset is messy in its own way”
6
Each variable is in a named column Each row is an
Easy to explore, plot, model, report. Easy way to think about data. Several powerful packages exist.
7
8
ggplot() ggplot(data =clover) ggplot(clover, aes(x = yarrow.s, y = clov.y))
Empty plot
The data
'data.frame':30 obs. of 3 variables: $ cycle : Factor w/ 3 levels "A","B","C": $ clov.y : num 14 50.7 11.4 23.1 32.2 18.5 $ yarrow.s: int 220 20 510 40 120 300 60 10
The aesthetic maps variables to axes ….but it doesn’t know what to plot
9 ggplot(clover, aes(x = yarrow.s, y = clov.y)) + geom_point()
geoms say what what the data should be plotted as
ggplot(clover, aes(x = yarrow.s, y = clov.y)) + geom_bar(stat = "identity") ggplot(clover, aes(x = yarrow.s, y = clov.y)) + geom_line()
...but will plot what you tell it, sensible or not
10
you can add
identity
11
All the figures you’ve ever done The cookbook for R ggplot2 cheatsheet The R Graph Gallery Googling and more googling
12
understand is the most important thing
variables are mapped to the horizontal axis, colours, shapes, sizes, facets
13