[rsplus] raı
Viewer
- # load required packages
- library(ggplot2)
- library(languageR)
- library(tidyverse)
- library(magrittr)
- # randomly select 10 rows from danish
- danish %>%
- sample_n(10)
- # calculate number of different words in danish
- danish %>%
- distinct(Word) %>%
- nrow()
- # calculate average response time for each affix
- danish %>%
- group_by(Affix) %>%
- summarise(mean_rt = mean(LogRT))
- # create linear plot showing relation between log word frequency and log RTs
- ggplot(data = danish, aes(x = LogWordFreq, y = LogRT)) +
- geom_smooth(method = "lm")
- # convert logRT to raw RTs
- danish %>%
- mutate(RT = exp(LogRT))
- # compute average RTs by Sex
- danish %>%
- group_by(Sex) %>%
- summarise(mean_rt = mean(LogRT))
- # plot histogram of RTs by Sex
- ggplot(data = danish, aes(x = LogRT)) +
- geom_histogram(color = "black", fill = "white") +
- facet_wrap(~Sex)
- # create 'frequency' variable and compute average RTs by frequency
- danish %>%
- mutate(freq = ifelse(LogWordFreq > median(LogWordFreq), "high freq", "low freq")) %>%
- group_by(freq) %>%
- summarise(mean_rt = mean(LogRT))
- # plot histogram of RTs by frequency
- ggplot(data = danish, aes(x = RT)) +
- geom_histogram(color = "black", fill = "white") +
- facet_wrap(~freq)
Editor
You can edit this paste and save as new: