R-code for Commentary

This page contains links to R code used to produce the figures for “Conspiracist Ideation as a Predictor of Climate Science Rejection: An Alternative Analysis” by Ruth M. Dixon and Jonathan A. Jones, a commentary published in Psychological Science, the accompanying online supplementary material, and the accompanying blog post.

Four R programs are provided as plain text in the linked pages:

  • paper.R produces the figure used in the paper
  • stats.R calculates the linear fit statistics used in the paper
  • SM.R produces the figures used in the supplementary material
  • blog.R produces the figures used in the blog post

These programs use relatively standard R, but rely heavily on the ggplot2 package.

The text in the four pages linked above should be copied and saved in text files named as indicated (name.R). The files should be saved in a single directory, together with the two data files LskyetalPsychSciClimate.csv and PLOSONE2013Data.csv which can be obtained from the original authors’ website (publications page of http://www.cogsciwa.com/), or using direct links for LOG13 and LGO13. The data for LOG13 is only available as an xls format excel file, but this can be opened and saved as a csv file. The code can then be run using, for example, the source command within the R interpreter. Output files will be saved in the same directory, and the output from stats.R appears in the interpreter window.

Note that because these plots use random jittering the scatter plots will vary subtly each time the code is run. These variations are of no importance, and the fitted lines (OLS straight lines and loess fits) are fitted to the original (unjittered) data. The titles on figures may not be identical to those used in the paper, but should be clear.

Advertisements