[rsplus] raı

Viewer

  1.  
  2. # load required packages
  3. library(ggplot2)
  4. library(languageR)
  5. library(tidyverse)
  6. library(magrittr)
  7.  
  8. # randomly select 10 rows from danish
  9. danish %>%
  10.   sample_n(10)
  11.  
  12. # calculate number of different words in danish
  13. danish %>%
  14.   distinct(Word) %>%
  15.   nrow()
  16.  
  17. # calculate average response time for each affix
  18. danish %>%
  19.   group_by(Affix) %>%
  20.   summarise(mean_rt = mean(LogRT))
  21.  
  22. # create linear plot showing relation between log word frequency and log RTs
  23. ggplot(data = danish, aes(= LogWordFreq, y = LogRT)) +
  24.   geom_smooth(method = "lm")
  25.  
  26. # convert logRT to raw RTs
  27. danish %>%
  28.   mutate(RT = exp(LogRT))
  29.  
  30. # compute average RTs by Sex
  31. danish %>%
  32.   group_by(Sex) %>%
  33.   summarise(mean_rt = mean(LogRT))
  34.  
  35. # plot histogram of RTs by Sex
  36. ggplot(data = danish, aes(= LogRT)) +
  37.   geom_histogram(color = "black", fill = "white") +
  38.   facet_wrap(~Sex)
  39.  
  40. # create 'frequency' variable and compute average RTs by frequency
  41.  
  42. danish %>%
  43.   mutate(freq = ifelse(LogWordFreq > median(LogWordFreq)"high freq""low freq")) %>%
  44.   group_by(freq) %>%
  45.   summarise(mean_rt = mean(LogRT))
  46.  
  47. # plot histogram of RTs by frequency
  48. ggplot(data = danish, aes(= RT)) +
  49.   geom_histogram(color = "black", fill = "white") +
  50.   facet_wrap(~freq)
  51.  
  52.  

Editor

You can edit this paste and save as new:


File Description
  • raı
  • Paste Code
  • 02 Dec-2022
  • 1.23 Kb
You can Share it: