{"id":13857390,"url":"https://github.com/mattansb/Practical-Applications-in-R-for-Psychologists","last_synced_at":"2025-07-13T21:32:32.644Z","repository":{"id":44916112,"uuid":"207517496","full_name":"mattansb/Practical-Applications-in-R-for-Psychologists","owner":"mattansb","description":"Lesson files for Practical Applications in R for Psychologists.","archived":false,"fork":false,"pushed_at":"2023-10-06T09:59:28.000Z","size":14607,"stargazers_count":126,"open_issues_count":10,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-18T15:45:07.442Z","etag":null,"topics":["bgu-university","easystats","psychologists","regression","rstats","statistics","teaching-materials","tidyverse"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattansb.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-09-10T09:26:36.000Z","updated_at":"2024-11-17T01:22:06.000Z","dependencies_parsed_at":"2024-02-09T01:57:29.591Z","dependency_job_id":null,"html_url":"https://github.com/mattansb/Practical-Applications-in-R-for-Psychologists","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FPractical-Applications-in-R-for-Psychologists","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FPractical-Applications-in-R-for-Psychologists/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FPractical-Applications-in-R-for-Psychologists/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FPractical-Applications-in-R-for-Psychologists/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattansb","download_url":"https://codeload.github.com/mattansb/Practical-Applications-in-R-for-Psychologists/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225920312,"owners_count":17545469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgu-university","easystats","psychologists","regression","rstats","statistics","teaching-materials","tidyverse"],"created_at":"2024-08-05T03:01:35.353Z","updated_at":"2024-11-22T15:30:38.834Z","avatar_url":"https://github.com/mattansb.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003cimg src='logo/Hex.png' align=\"right\" height=\"139\" /\u003e\n\n```{r setup, include=FALSE}\nlibrary(knitr)\n\nopts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)\n\nextract_pkgs \u003c- function(fl) {\n  if (length(fl) == 1) {\n    txt \u003c- read.delim(fl, header = FALSE)[[1]] |\u003e \n      paste0(collapse = \"\\n\")\n    \n    pkg_lib \u003c- stringr::str_extract_all(txt, pattern = \"(?\u003c=library\\\\().{1,}?(?=\\\\))\")\n    \n    pkg_req \u003c- stringr::str_extract_all(txt, pattern = \"(?\u003c=require\\\\().{1,}?(?=\\\\))\")\n    \n    pkg_name \u003c- stringr::str_extract_all(txt, pattern = \"[a-z|A-Z|0-9]{1,}(?=\\\\:\\\\:)\")\n    \n    pkgs \u003c- c(pkg_lib, pkg_req, pkg_name)\n    \n  } else if (length(fl) \u003e 1) {\n    pkgs \u003c- sapply(fl, extract_pkgs)\n  }\n  \n  pkgs |\u003e\n    unlist(recursive = TRUE) |\u003e \n    as.vector() |\u003e \n    unique()\n}\n\nmake_pkg_table \u003c- function(pkgs) {\n  # pkgs \u003c- pkgs[sapply(pkgs, function(x) length(x) \u003e 0)]\n  \n  new_pkgs \u003c- lapply(seq_along(pkgs), function(i) {\n    lesson_pkgs \u003c- pkgs[[i]]\n    prev_lesson_pkgs \u003c- unlist(head(pkgs,i-1))\n    \n    !lesson_pkgs %in% prev_lesson_pkgs\n  })\n  \n  \n  ps \u003c- sapply(seq_along(pkgs), function(idx) {\n    x \u003c- pkgs[[idx]]\n    is_new \u003c- ifelse(new_pkgs[[idx]], \"**\", \"\")\n    paste0(\n      glue::glue(\"[{is_new}`{x}`{is_new}](https://CRAN.R-project.org/package={x})\"),\n      collapse = \", \"\n    )\n  })\n  \n  c(\"|Lesson|Packages|\\n|----|----|\\n\", # header\n    glue::glue(\"|[{folder}](/{folder})|{ps}|\\n\\n\",\n             folder = names(pkgs))) |\u003e \n    paste0(collapse = \"\")\n}\n\nget_src \u003c- function(pkg) {\n  pd \u003c- packageDescription(pkg)\n  if (is.null(src \u003c- pd$Repository)) {\n    if (!is.null(src \u003c- pd$GithubRepo)) {\n      src \u003c- paste0(\"Github: \",pd$GithubUsername,\"/\",src)\n    } else {\n      src \u003c- \"Local version\"\n    }\n  }\n  return(src)\n}\n```\n\n# Practical Applications in R for Psychologists\n\n[![](https://img.shields.io/badge/Open%20Educational%20Resources-Compatable-brightgreen)](https://creativecommons.org/about/program-areas/education-oer/)\n[![](https://img.shields.io/badge/CC-BY--NC%204.0-lightgray)](http://creativecommons.org/licenses/by-nc/4.0/)  \n[![](https://img.shields.io/badge/Language-R-blue)](http://cran.r-project.org/)\n\n\u003csub\u003e*Last updated `r Sys.Date()`.*\u003c/sub\u003e\n\nThis Github repo contains all lesson files for *Practical Applications in R for Psychologists*. The goal is to impart students with the basic tools to process data, describe data (w/ summary statistics and plots), and the foundations of **building, evaluating and comparing statistical models in `R`**, focusing on linear regression modeling (using both frequentist and Bayesian approaches).\n\n\nThese topics were taught in the graduate-level course ***Advanced Research Methods for Psychologists*** (Psych Dep., Ben-Gurion University of the Negev), laying the foundation for the following topic-focused courses:\n\n- [Hierarchical linear models (*HLM*)](https://github.com/mattansb/Hierarchical-Linear-Models-foR-Psychologists)\n- [Machine Learning (*ML*)](https://github.com/mattansb/Machine-Learning-foR-Psychologists)\n- [Structural equation modelling (*SEM*)](https://github.com/mattansb/Structural-Equation-Modeling-foR-Psychologists)\n- [Analysis of Factorial Designs (*ANOVA*)](https://github.com/mattansb/Analysis-of-Factorial-Designs-foR-Psychologists)\n\n**Notes:**  \n\n- This repo contains only materials relating to *Practical Applications in R*. Though statistics are naturally discussed in many lessons, the focus is generally on the application and not on the theory.  \n- Please note that some code does not work *on purpose* and without warning, to force students to learn to debug.\n\n## Setup\n\nYou will need:\n\n1. A fresh installation of [**`R`**](https://cran.r-project.org/) (preferably version 4.1.1 or above).\n2. [RStudio IDE](https://www.rstudio.com/products/rstudio/download/) (optional, but recommended).\n3. The following packages, listed by lesson:\n\n```{r, echo=FALSE}\nr_list \u003c- list.files(pattern = \".(R|r)$\", recursive = TRUE, full.names = TRUE) |\u003e \n  Filter(f = \\(x) !stringr::str_detect(x, pattern = \"(SOLUTION|logo)\"))\n\nlesson_names \u003c- stringr::str_extract(r_list, pattern = \"(?\u003c=(/)).{1,}(?=(/))\")\n\nr_list \u003c- split(r_list, lesson_names)\n\npkgs \u003c- lapply(r_list, extract_pkgs)\n\nprint_pkgs \u003c- make_pkg_table(pkgs)\n```\n\n`r print_pkgs`\n\n\u003csub\u003e*(Bold denotes the first lesson in which the package was used.)*\u003c/sub\u003e\n\nYou can install all the packages used by running:\n\n```{r echo=FALSE, comment = \"\", warning=FALSE}\nunique_pkgs \u003c- pkgs |\u003e \n  unlist(recursive = TRUE) |\u003e \n  unique() |\u003e sort()\n\npackinfo \u003c- installed.packages(fields = c(\"Package\", \"Version\"))\n# unique_pkgs[!is.element(unique_pkgs, rownames(packinfo))]\nV \u003c- packinfo[unique_pkgs,\"Version\"]\nsrc \u003c- sapply(unique_pkgs, get_src)\n\ncat(\"# in alphabetical order:\")\n\ncat(\"pkgs \u003c-\", dput(unique_pkgs) |\u003e capture.output(), fill = 80) |\u003e \n  capture.output() |\u003e \n  styler::style_text()\n\ncat('install.packages(pkgs, repos = c(\"https://easystats.r-universe.dev\", getOption(\"repos\")))')\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003ePackage Versions\u003c/i\u003e\u003c/summary\u003e\n\nRun on `r osVersion`, with R version `r packageVersion(\"base\")`.\n\nThe packages used here:\n\n```{r, echo=FALSE}\nv_info \u003c- paste0(glue::glue(\" - `{unique_pkgs}` {V} (*{src}*)\"), collapse = \"\\n\")\n```\n\n`r v_info`\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2FPractical-Applications-in-R-for-Psychologists","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattansb%2FPractical-Applications-in-R-for-Psychologists","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2FPractical-Applications-in-R-for-Psychologists/lists"}