Replication of Xu and Tenenbaum 2007a, Experiment 1. N = 50 participants (original: N = 22).

Read in raw data and anonymize

files = dir("../production-results/")
d = data.frame()
for (i in 1:length(files)[1]) {
    s <- fromJSON(paste("../production-results/", files[i], sep = ""))
    s$answers$asses = ifelse (is.null(s$answers$asses), "NA", s$answers$asses)
    d = rbind(d, data.frame(s))
}
names(d) <- str_replace(names(d), "answers.", "")
d.anonymized <- anonymize.sids(d, "WorkerId")

write.csv(d.anonymized, "exp1_A.csv")

Munge

d = read.csv("exp1_A.csv")

d.long = d %>%
  gather(variable, value, contains("_")) %>%
  mutate(trial_num =  unlist(lapply(strsplit(as.character(variable),
                                      "_T"),function(x) x[2])),
         variable = unlist(lapply(strsplit(as.character(variable),
                                      "_"),function(x) x[1]))) %>%
  spread(variable, value) %>%
  mutate(trial_num = as.numeric(trial_num)) %>%
  mutate_if(is.character, funs(as.factor)) 

d.munged = d.long %>%
          select(subids, trial_num, category, condition, selected) %>%
          mutate(selected = lapply(str_split(selected, ","), 
                                   function(x) {str_sub(x, 4, 6)})) %>%
          mutate(prop_sub = lapply(selected, function(x){sum(x == "sub")/2}),
                 prop_bas = lapply(selected, function(x){sum(x == "bas")/2}),
                 prop_sup = lapply(selected, function(x){sum(x == "sup")/4})) %>%
          select(-selected)

Reproduce XT2007a Figure 5.

ms = d.munged %>%
  gather(variable, value, c(prop_sub, prop_bas, prop_sup)) %>%
  group_by(condition,variable) %>%
  mutate(value = as.numeric(value)) %>%
  multi_boot_standard(column = "value")  %>%
  mutate(variable = as.factor(variable))

ms$variable = factor(ms$variable,levels(ms$variable)[c(2,1,3)])
ms$condition = factor(ms$condition,levels(ms$condition)[c(1,3,2,4)])
ms$condition = plyr::mapvalues(ms$condition,
                               from = c("one", "three_basic", 
                                        "three_subordinate",
                                        "three_superordinate"), 
                               to = c("1", "3 basic", "3 sub.", "3 super."))

ggplot(ms, aes(x = condition, y = mean, group = variable, fill = variable)) +
  geom_bar(position = "dodge", stat = "identity") +
  geom_linerange(aes(ymin = ci_lower, 
                     ymax = ci_upper), 
                 position=position_dodge(width = .9)) +
  ylab("Proportion of \ntest objects chosen") +
  xlab("Examples") +
  theme_bw() +
  theme(legend.title = element_blank())

XT 2007a, Figure 5 (for reference)

XT 2007a, Figure 5 (for reference)

By category

ms = d.munged %>%
  gather(variable, value, c(prop_sub, prop_bas, prop_sup)) %>%
  mutate(variable = as.factor(variable)) %>%
  group_by(condition,variable,category) %>%
  mutate(value = as.numeric(value)) %>%
  multi_boot_standard(column = "value") 

ms$variable = factor(ms$variable,levels(ms$variable)[c(2,1,3)])
ms$condition = factor(ms$condition,levels(ms$condition)[c(1,3,2,4)])
ms$condition = plyr::mapvalues(ms$condition,
                               from = c("one", "three_basic", 
                                        "three_subordinate", "three_superordinate"), 
                               to = c("1", "3 basic", "3 sub.", "3 super."))

ggplot(ms, aes(x = condition, y = mean, group = variable, fill = variable)) +
  facet_grid(~category) +
  geom_bar(position = "dodge", stat = "identity") +
  geom_linerange(aes(ymin = ci_lower, 
                     ymax = ci_upper), 
                 position=position_dodge(width = .9)) +
  ylab("Proportion of \ntest objects chosen") +
  xlab("Examples") +
  theme_bw() +
  theme(legend.title = element_blank())