Objectives

By the end of this assignment, you should:

This assignment is due Thursday, September 16th at noon. You should complete the assignment in the .Rmd template. Please turn your .html AND .Rmd files into Canvas. Your .Rmd file should knit without an error before turning in the assignment. If you need help, there a lot of resources available to you. Please reach out if you’re stuck.


To get started, you’ll need to download and open up the Rmarkdown template in RStudio. The first few exercises focus on data from the Lewis & Frank (2018) replication of the Xu and Tenenbaum (2007) experiment (that we talked about in lecture). We’ll be working with data from the first experiment only. For reference, the journal paper write up of this study can be found here, and you can see the actual experiment that participants saw here.

The data are in a file called lewis_2018_exp1.csv that lives on the internet. We can load the data into R by passing the online filepath to the read_csv() function. Once we read it into R, we can save it to a variable called lf_data:

lf_data <- read_csv("https://raw.githubusercontent.com/mllewis/cumulative-science/master/static/data/lewis_2018_exp1.csv")

There are six variables in the data and each variable is described below. The first six rows of the data frame are also displayed below.

exp subids trial_num category condition proportion_basic_level_responses
1 1 9 vehicles three_subordinate 0
1 2 9 animals three_basic 1
1 3 9 animals three_superordinate 1
1 4 9 vehicles three_superordinate 1
1 5 9 animals three_superordinate 1
1 6 9 vegetables three_subordinate 0


  1. Is this dataset tidy? Describe the smallest unit of observation in this dataset.


  1. Select the columns subids, category, proportion_basic_level_responses from the data. Print the first six rows of this data frame.


  1. Print the first six rows of a data frame excluding the category column.


  1. Use logical tests and Boolean operators to return only the rows that contain trials (rows): [a] with category as vegetables, [b] with category as vehicles and a trial greater than 3, [c] with category as vegetables or animals, [d] with at least one basic level response in the “one” condition.


  1. The following code selects all trials (rows) where the condition was either “three_subordinate” or “one.” Rewrite this code in a way that uses the %in% operator.
filter(lf_data, condition == "three_subordinate" | condition == "one")


  1. How many trials are there where the category is either vegetables or animals? Use nrow().


  1. The three following sets of commands are written without the pipe operator (%>%). Rewrite each one to include the pipe.

[a]

var1 <- mutate(lf_data, category)

[b]

var1 <- select(lf_data, category)
var2 <- nrow(var1)

[c]

var1 <- filter(lf_data, trial_num == 1)
var2 <- filter(var1, category == "animals")
var3 <- select(var2, trial_num, category)


  1. The two following sets of commands are written with the pipe operator. Rewrite each one to exclude the pipe.

[a]

lf_data %>%
  filter(trial_num < 6) %>%
  nrow()

[b]

lf_data %>%
  select(subids, category, proportion_basic_level_responses) %>%
  filter(subids == 1) %>%
  arrange(category)


  1. Look at the code below. Describe in full sentences what this code does.
lf_data %>%
  select(subids, category, condition) %>%
  filter(category == "vehicles" & condition != "one") %>%
  arrange(-subids)


  1. On the first day of class, we talked about the “Sally Anne Task” that measures children’s understanding of theory of mind (example videos). Describe four variables that you could measure in this task to assess children’s theory of mind performance. Specifically, describe (1) one qualitative variable, (2) one quantitative - binary variable, (3) one quantitative - numeric, and (4) one quantitative - real variable. For each variable, give a one sentence description of the variable, AND one example value of that variable with units.


  1. Describe the ways in which the scientific process could be described as a “social endeavor”. Your answer should make reference to the concepts of “replication” and “reproducibility”. Please respond with a short paragraph.
LS0tCnRpdGxlOiAiQXNzaWdubWVudCAxOiBDdW11bGF0aXZlIFNjaWVuY2UgYW5kIEludHJvIHRvIGRwbHlyIgpzdWJ0aXRsZTogIk1vZGVybiBSZXNlYXJjaCBNZXRob2RzIgpvdXRwdXQ6CiAgaHRtbF9kb2N1bWVudDoKICAgIGNvZGVfZG93bmxvYWQ6IHRydWUKICAgIGNzczogLi4vbGFiLmNzcwogICAgaGlnaGxpZ2h0OiBrYXRlCiAgICB0aGVtZTogY29zbW8KICAgIHRvYzogZmFsc2UKICAgIHRvY19mbG9hdDogZmFsc2UKLS0tCgpgYGB7ciBnbG9iYWxfb3B0aW9ucywgaW5jbHVkZSA9IEZ9CmxpYnJhcnkodGlkeXZlcnNlKQpsaWJyYXJ5KGtuaXRyKQpgYGAKCgo8YnI+Cjxicj4KPGRpdiBpZD0iYm94ZWR0ZXh0Ij4KCiA8Zm9udCBzaXplPSI0Ij4gKipPYmplY3RpdmVzKiogPC9mb250PiAKIApCeSB0aGUgZW5kIG9mIHRoaXMgYXNzaWdubWVudCwgeW91IHNob3VsZDoKCi0gdW5kZXJzdGFuZCB0aGUgY29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