Materials for PSY 611: Data Analysis I
This guide covers how to:
- Pull the latest site
- Edit/add a lab
.Rmdand update the navbar - Render the site locally
- Push your changes to GitHub
-
Open
_site.ymland note:output_dir: "."→ HTML files are written next to their.Rmd(e.g.,labs/lab-6.Rmd→labs/lab-6.html).- Navbar structure: “Labs” uses explicit
href:entries likelabs/lab-1.html,labs/lab-2_student.html, etc. You must add your new lab to this list to expose it in the nav. output: html_document: self_contained: nowithlib_dir: site_libs→ shared JS/CSS go insite_libs/. Commit any changes there if they’re created/updated.
RStudio (Git pane):
- Open the project in RStudio.
- Git pane → Pull.
Command line:
git checkout main
git pull origin main
# (recommended) work on a branch
git checkout -b lab-XX-update-
Labs live in
labs/and are single files named likelab-1.Rmd,lab-2_student.Rmd, etc. -
To create a new lab (example: Lab 10):
-
Create
labs/lab-10.Rmdwith a minimal header like:--- title: "Lab 10: <Short Title>" output: html_document: toc: true toc_depth: 3 number_sections: false ---
-
Add your content below the header (use relative paths for any data/images).
-
-
Match the existing naming style. If earlier weeks use suffixes (e.g.,
_student,_ist), keep your naming consistent.
-
Open
_site.yml, find the Labs menu block, and add a new entry that exactly matches your intended output filename:- text: "Lab 10" href: "labs/lab-10.html"
-
Keep indentation consistent (YAML is whitespace-sensitive).
-
If existing entries use a different label format (e.g., “Lab 2”), copy that style.
- Save
labs/lab-XX.Rmdand_site.yml.
Option A — Render just your lab file (fastest while drafting):
-
In RStudio, open
labs/lab-XX.Rmdand click Knit; or run:rmarkdown::render("labs/lab-XX.Rmd")
-
This produces
labs/lab-XX.html. Open it to check content.
Option B — Build the whole site (updates navbar + all pages):
-
In RStudio: Build → Build Website (or Ctrl/Cmd + Shift + B).
-
Or in the R console:
rmarkdown::render_site()
Check that:
- The navbar shows your new lab under “Labs”.
- The link points to the correct HTML (
labs/lab-XX.html). - Images/data load and code chunks run.
RStudio (Git pane):
- Stage changed files (e.g.,
labs/lab-XX.Rmd,_site.yml, and any newly createdlabs/lab-XX.htmlplus updates tosite_libs/if present). - Commit with a clear message, e.g.,
Add Lab XX and navbar entry; render site. - Push your branch. Open a Pull Request on GitHub if you’re using branches.
Command line:
git add labs/lab-XX.Rmd _site.yml
# If new/updated HTML or site_libs were generated:
git add labs/lab-XX.html site_libs/ || true
git commit -m "Add Lab XX and navbar entry; render site"
git push -u origin lab-XX-updateIf using a branch, open a Pull Request on GitHub, add a short description, and request review.
Deployment notes:
- If GitHub Pages serves from the repo root (and you commit the rendered
.htmlfiles), merging tomainupdates the live site. - If CI/Netlify is used, merging usually triggers a deploy automatically.
- Navbar link 404: Ensure the
href:exactly matches the rendered filename (e.g.,labs/lab-2_student.html, notlabs/lab-2.html). - YAML indentation errors: Recheck spacing in
_site.ymland the Rmd header. - Missing assets: With
self_contained: no, make suresite_libs/and any referenced images/data are tracked and pushed if they’re new/changed. - Consistent naming: Follow existing patterns in
_site.ymlso the nav stays orderly and predictable.
# 1) Pull latest
git checkout main
git pull origin main
git checkout -b lab-XX-update
# 2) Edit
# - labs/lab-XX.Rmd
# - _site.yml (add Labs menu item pointing to labs/lab-XX.html)
# 3) Render
R -q -e "rmarkdown::render('labs/lab-XX.Rmd')"
R -q -e "rmarkdown::render_site()"
# 4) Commit & push
git add labs/lab-XX.Rmd _site.yml labs/lab-XX.html site_libs/ || true
git commit -m "Add Lab XX and navbar entry; render site"
git push -u origin lab-XX-update