Posts

Showing posts with the label data visualisation

Jittering in R (ggplot2)

Image
Jittering is the act of adding random noise to data in order to prevent overplotting in statistical graphs. Overplotting can occur when a continuous measurement is rounded to a convenient unit. This has the effect of making a continuous variable appear like a discrete ordinal variable.  For example, age is measured in years and body weight is measured in pounds or kilograms.  A scatter plot of weight versus age, which includes a sufficiently large sample of people will involve considerable overlap. Many individuals may be recorded as, 29 years old and weighing 70 kg, and there will be many markers plotted at the point (29, 70). The same is often true when plotting other individual difference metrics throughout psychology (e.g. personality) (Figure 1). Figure 1: Before Jittering - a significant positive correlation between x & y [r = .37]. To alleviate overplotting, it is possible to add a small amount of random noise to the data...

Word Clouds with Processing and R

Image
I've previously relied on  wordle.net to produce 'word clouds'. These clouds give greater prominence to words that appear more frequently in a source text. However, it is also possible to produce similar, highly customisable word clouds in Processing and R . Processing relies on the excellent  WordCram library. This is straightforward to install and can take any text file or website and produce a word cloud. The source code below demonstrates the variety of presentation options that are available. While the WordCram extension allows for some nice visual tricks, the text file has to be free of any undesirable additional variables or words that may need be excluded before creating a word cloud. In other words, Processing doesn't allow for any advanced text mining techniques e.g. you might want to remove all numbers or specific words form a file before producing a word cloud. R becomes more useful in this instance. Combining the tm  (text mining) and wordcloud p...

Arranging Multiple Plots in R

Image
Arranging several plots in R as part of a grid isn't always straightforward. Imagine you had three plots and wanted one to stretch along the bottom row and place the other two above (i.e. Figure 1). Figure 1: Sketch of intended placement Using grid.arrange , it is possible to plot several outputs, but the function will automatically place them into a default grid structure (Figure 2). grid.arrange(p1, p2, p3, p4, p5, p6, p7, p8, p9) Figure 2: Using grid.arrange This may be perfectly adequate if they are to be of equal size. However, this isn't always ideal. For example, when aligning the plots below, the result becomes cluttered (Figure 3). grid.arrange(p3, p4, p5) Figure 3: Work in progress As per my original sketch, I want the top plot (with no legend) to run along the bottom row and the other two plots to be positioned side by side above. The following example shows how this can be accomplished. First, a new layout is created, here a...

Working 9-5, what a way to measure social behaviour outside the lab: Introducing Sociometric Sensors.

Image
At The University of Lincoln , we have recently taken delivery of several  Sociometric sensors !! Until very recently it was impossible to record social signalling in natural settings with a high level of precision over time. While observers have been employed in the past, their observations are inherently subjective, expensive and often inaccurate. However, advances in electronic measurement sensors, reduction in battery sizes and developments in computational data analysis have facilitated the measurement of what was previously deemed invisible. As a result, there is a growing body of evidence suggesting that social signalling plays a significant role in everyday persuasion and decision making, with applications extending to analysis and redesign of organisational networks. A Sociometric sensor (Figure 1) is a small electronic device worn around the neck. It measures a variety of individual and interpersonal behaviours during a social interaction by way of four sensors...