

In the example above, I have also customised the smoothed line, making it grey We can add this to the scatter plot like so: mtcars %>% ggplot( aes( x = disp, y = mpg, colour=hp)) + geom_point( size= 2) + geom_smooth( se=F, colour= "grey") Scatter plots, or geom_line() for line plots, or geom_smooth() for a These visual layers are called geom’s and theįunctions which add them are all prefixed with geom_, so geom_point() for What’s even neater about ggplot though is how easy it is to layer different Numeric variable when colouring the points? Use the airquality dataset and create your own scatterplot and try to colour Say we want to make a scatter plot, and so draw points for each row of data: mtcars %>% ggplot( aes( x = disp, y = mpg, colour=hp)) + geom_point()Īnd we have a pretty slick graph: ggplot has now added points for each pair ofĭisp and mpg values, and coloured them according to the value of hp (see To display data, we have to add a visual layer to the plot. mtcars %>% ggplot( aes( x = disp, y = mpg, colour=hp)) For this we need to add visual display layers (in We also tell it to colour the points differently depending on theĪt this point ggplot will create and label the axes and plot area, but doesn’t Here we tell ggplot to use disp (engine size) on the x axis, and mpg on


Number or type of variables you want to display. You should be guided in choosing plots not by mechanical rules based on the Within the bar, even though this is typically not the case). (specifically, when bar graphs are used to display estimates which containĮrror, readers assume points above the bar are less likely than points Perhaps most importantly, even when they include error bars, readersĬonsistently misinterpret the quantitative information in bar graphs
#Pdf images have a waffle appearance series#
Make comparisons between multiple data series very difficult (for example in But bar graphs have numerousĭisadvantages over other plots which can show the same information.Īre low in information density (and so inefficient in use of space) Which plots are the most effective forms of communication.įor example, almost all guides to plotting, and especially R textbooks, will Plot types are perhaps not as useful as those which reflect our knowledge of
#Pdf images have a waffle appearance full#
However, guides which attempt to be comprehensive and show you a full range of ‘Show me the numbers’ chart guide (pdf).There are various simple chart selection guides available online, of which these Like maps, models are imperfect but useful.Dichotomising continuous predictors (or outcomes).Forgetting that the CI depends on sample size.‘Poking around’ with $ and Save time: use a broom.Making prdictions for margins ( effects of predictors).For multilevel or generalised linear models.Baysian fitting of linear models via MCMC methods.Mediation example after Baron and Kenny.Convergence problems and simplifying the random effects structure.Contrasts and followup tests using lmer.3 level models with ‘partially crossed’ random effects.Variance partition coefficients and intraclass correlations.Allow the effect of sleep deprivation to vary for different participants.Repeated measures or ‘split plot’ designs.Describing statistical models using formulae.Aggregating and reshaping at the same time.

Which package should you use to reshape data?.Differences in quantity: numeric variables.
