A Priming study
In a provocative paper, Bargh, Chen and Burrows (1996) sought to test whether or not priming people with trait concepts would trigger trait-consistent behavior. In one study, they primed participants with either neutral words (e.g.; bat, cookie, pen), or with words related to an elderly stereotype (e.g.; wise, stubborn, old). They then, unbeknownst to the participants, used a stopwatch to record how long it took the participants to walk down a hallway at the conclusion of an experiment. They predicted that participants primed with words related to the elderly would walk slower than those primed with neutral words.
In this WPA, you will analyze fake data corresponding to this study.
Dataset description
Our fake study has 3 primary independent variables:
prime
: What kind of primes was the participant given?neutral
means neutral primes,elderly
means elderly primes.prime.duration
: How long (in minutes) were primes displayed to participants? There were 4 conditions: 1, 5, 10 or 30.grandparents
: Did the participant have a close relationship with their grandparents?yes
means yes,no
means no,none
means they never met their grandparents.
There was one primary dependent variable
walk
: How long (in seconds) did participants take to walk down the hallway?
There were 4 additional variables:
id
: The order in which participants completed the studyage
: Participants’ agesex
: Participants’ sexattention
: Did the participant pass an attention check? 0 means they failed the attention check, 1 means they passed.
Project management
Start a new R-project called
RCourse
(or something similar). Then (either within RStudio or outside of R), navigate to the location of yourRCourse
project, and add the foldersR
anddata
.Open a new R script called
wpa_3_LASTFIRST.R
(where LASTFIRST is your last and first name), and save it in theR
folder.The text file containing the data is called
priming.txt
. It is available at http://nathanieldphillips.com/wp-content/uploads/2016/10/priming.txt. Right-click the link and save the file in thedata
folder.Using
read.table()
load the data into a new R object calledpriming
. Note that the text file is tab–delimited and contains a header row, so be sure to include thesep = "\t"
andheader = TRUE
arguments!
Understanding and cleaning the data
Get to know the data using
View()
,summary()
,head()
andstr()
.Look at the names of the dataframe with
names()
. Those aren’t very informative are they? Change the names to the correct values (make sure to use the naming scheme I describe in the dataset description).
Applying functions to columns
What was the mean participant age?
How many participants were there from each sex?
What was the median walking time?
What percent of participants passed the attention check (Hint: To calculate a percentage from a 0, 1 variable, use
mean()
)Walking time is currently in seconds. Add a new column to the dataframe called
walking.m
That shows the walking time in minutes rather than seconds.
Indexing and subsettting dataframes
Try to split your answers to these problems into two steps
Step 1: Index or subset the original data and store as a new object with a new name.
Step 2: Calculate the appropriate summary statistic using the new, subsetted object you just created.
What were the sexes of the first 10 participants?
What was the data for the 50th participant?
What was the mean walking time for the elderly prime condition?
What was the mean walking time for the neutral prime condition?
What was the mean walking time for participants less than 23 years old?
What was the mean walking time for females with a close relationship with their grandparents?
What was the mean walking time for males over 24 years old without a close relationship with their grandparents?
Checkpoint! If you got this far you are doing great!
Creating new dataframe objects
Create a new dataframe called
priming.att
that only includes rows where participants passed the attention check. (Hint: use indexing orsubset()
)Some of the data don’t make any sense. For example, some walking times are negative, some prime values aren’t correct, and some prime.duration values weren’t part of the original study plan. Create a new dataframe called
priming.c
(aka., priming clean) that only includes rows with valid values for each column – do this by looking for an few strange values in each column, and by looking at the original dataset description. Additionally, only include participants who passed the attention check. Here’s a skeleton of how your code should look
# Create priming.c, a subset of the original priming data
# (replace __ with the appropriate values)
priming.c <- subset(priming,
subset = sex %in% c(_____) &
age > ____ &
attention == ___ &
prime %in% c(___) &
prime.duration %in% c(___) &
grandparents %in% c(___) &
walk > ___ )
How many participants gave valid data and passed the attention check? (Hint: Use the result from your previous answer!)
Of those participants who gave valid data and passed the attention check, what was the mean walking time of those given the elderly and neutral prime (calculate these separately).
Saving and loading data
Save your two dataframe objects
priming
andpriming.c
in an .RData file calledpriming.RData
in the data folder of your projectSave your
priming.c
object as a tab–delimited text file calledpriming_clean.txt
in the data folder of your project.Clean your workspace by running
rm(list = ls())
Re-load your two dataframe objects using
load()
.A colleague of yours wants access to the data from the females given the neutral prime in your experiment. Create a dataframe called
priming.f
that only includes these data. Additionally, do not include theid
column as this could be used to identify the participants.Save your
priming.f
object as a tab–delimited text file calledpriming_females.txt
in the data folder of your project.Save your entire workspace using to an .RData file called
priming_ws.RData
in the data folder of your project.
Challenges
The following questions apply to your cleaned dataframe (priming.c
)
Did the effect of priming condition on walking times differ between the first 100 and the last 100 participants (Hint: Make sure to index the data using
id
!)?Due to a computer error, the data from every participant with an even id number is invalid. Remove these data from your
priming.c
dataframe.Do you find evidence that a participant’s relationship with their grandparents affects how they responded to the primes?
Submit!
Save and email your wpa_X_LastFirst.R
file to me at nathaniel.phillips@unibas.ch. Then, go to https://goo.gl/forms/UblvQ6dvA76veEWu1 to complete the WPA submission form.