R Blog

(A collection of posts that also appear on my R blog - also on R-Bloggers.com)


A Shiny App for Tracking Moral Networks

Background This is a post outlining a ShinyApp that I made for visualising inter-participant agreement on quesions relating to Haidt’s Moral Foundations (e.g., Haidt and Joseph 2008). This is part of a line of research on moral judgements, inspired by DAFINET project, where I aim to investigate the role of agreement with others in the robustness of moral judgements. It is very early days and for the moment I am just playing around with the possible methods.

A Shiny App for JS Mediation

Background This is a brief post about making my first Shiny App (see also). I made this app following a meeting of the Advancing Social Cognition lab (ASC-Lab) where we discussed this paper by Yzerbyt et al. (2018) proposing a new method for mediation analysis. Any attempt to detail the differences in methods is well beyond the scope of a blog post. The take home message is that the method proposed by Yzerbyt et al.

R Markdown Workshop

Background This is an unusual post for me, I have avoided writing about R Markdown because there are so many resources already available on the topic (e.g., here, here, and here). However, recently I ran a session on using RMarkdown for my colleagues in the Centre for Social Issues Research. The aim of this was to demonstrate the usefulness of R Markdown (and hopefully convert a few people). For this session I created a set of resources1 aimed at making the transition from SPSS to R Markdown a bit easier.

A Lazy Function

It has been quite a while since I posted, but I haven’t been idle, I completed my PhD since the last post, and I’m due to graduate next Thursday. I am also delighted to have recently been added to R-bloggers.com so I’m keen to get back into it. A Lazy Function I have already written 2 posts about writing functions, and I will try to diversify my content. That said, I won’t refrain from sharing something that has been helpful to me.

Writing functions - Part two

(This post originally appeared on my R blog) The current post will follow on from the previous post and describe another use for writing functions. R Markdown and reporting p values in APA format The function described here is designed for use with R Markdown. I would write a post about how great R Markdown is, and how to use it, but there is already a wealth of information out there; see here, here, and here for a sample.

Writing functions - Part one

(This post originally appeared on my R blog) Writing functions This post outlines the writing of a basic function. Writing functions in R (R Core Team 2017) is fairly simple, and the usefulness of function writing cannot be conveyed in a single post. I have included “Part one” in the title, and I will add follow-up posts in time. The basic code to write a function looks like this:

Creating a dataframe

Creating a dataframe from raw participant data - Multiple files One of the most useful functions I’ve found in R is the ability to read individual data files and combine them into a dataframe. The power of this functionality marks a massive improvement from the days of copy and paste from excel into SPSS (IBM Corp, 2015). This post outline how to create a dataframe in R from a large number of individual data files.