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 study
  • age: Participants’ age
  • sex: Participants’ sex
  • attention: Did the participant pass an attention check? 0 means they failed the attention check, 1 means they passed.

Project management

  1. Start a new R-project called RCourse (or something similar). Then (either within RStudio or outside of R), navigate to the location of your RCourse project, and add the folders R and data.

  2. Open a new R script called wpa_3_LASTFIRST.R (where LASTFIRST is your last and first name), and save it in the R folder.

  3. 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 the data folder.

  4. Using read.table() load the data into a new R object called priming. Note that the text file is tab–delimited and contains a header row, so be sure to include the sep = "\t" and header = TRUE arguments!

Understanding and cleaning the data

  1. Get to know the data using View(), summary(), head() and str().

  2. 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

  1. What was the mean participant age?

  2. How many participants were there from each sex?

  3. What was the median walking time?

  4. What percent of participants passed the attention check (Hint: To calculate a percentage from a 0, 1 variable, use mean())

  5. 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.

  1. What were the sexes of the first 10 participants?

  2. What was the data for the 50th participant?

  3. What was the mean walking time for the elderly prime condition?

  4. What was the mean walking time for the neutral prime condition?

  5. What was the mean walking time for participants less than 23 years old?

  6. What was the mean walking time for females with a close relationship with their grandparents?

  7. 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

  1. Create a new dataframe called priming.att that only includes rows where participants passed the attention check. (Hint: use indexing or subset())

  2. 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 > ___ )
  1. How many participants gave valid data and passed the attention check? (Hint: Use the result from your previous answer!)

  2. 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

  1. Save your two dataframe objects priming and priming.c in an .RData file called priming.RData in the data folder of your project

  2. Save your priming.c object as a tab–delimited text file called priming_clean.txt in the data folder of your project.

  3. Clean your workspace by running rm(list = ls())

  4. Re-load your two dataframe objects using load().

  5. 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 the id column as this could be used to identify the participants.

  6. Save your priming.f object as a tab–delimited text file called priming_females.txt in the data folder of your project.

  7. 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)

  1. 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!)?

  2. 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.

  3. 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.