Week 4 · Advanced Statistical Programming using R
What is the main purpose of the {reprex} package?
git commitAnswer: 2) reprex::reprex() runs clipboard code in a fresh session and copies formatted output back.
Which of the following is NOT a typical Quarto rendering error?
:)@fig-xxx with no label)Answer: 4) An R argument error happens during code execution. The others are pre-execution errors.
Which is the best commit message according to the lecture?
"fix""changes to file""Add penguin species filter""It works. Don't touch!"Answer: 3) Good commit messages are short imperative summaries describing what and why.
Which should NOT be committed to Git? (multiple correct answers)
analysis.R — your main analysis script.env — API keys and credentials.Rhistory — R session history_site/ — rendered Quarto outputAnswer: 2, 3 & 4. Only analysis.R belongs in Git. Secrets, session artefacts, and build outputs go in .gitignore.
How does Git internally store the changes you commit?
Answer: 2) Each commit is a snapshot plus a parent pointer, author, timestamp, and message. Git shows diffs but doesn’t store them that way.
You deleted analysis.R two commits ago. Which command does NOT restore it?
git checkout <hash> -- analysis.Rgit revert <hash>git pull origin maingit diff <B> <A> | git applyAnswer: 3) git pull syncs with the remote — it doesn’t recover deleted files.
What is the key difference between forking and cloning?
Answer: 2) A fork lives on GitHub. A clone lives on your machine.
You want to push a local repo to a new (empty) GitHub repo. Which sequence works?
git push onlygit remote add origin <url> → git branch -M main → git push -u origin maingit fork <url> → git pushgit clone <url> → git pushAnswer: 2) Connect the remote, set the branch name, push with -u to set the upstream. After this, git push works.
You run git push and GitHub rejects it. Most likely cause and fix?
git pull first, then pushgit init — initialise and retryAnswer: 1) A rejected push usually means someone pushed commits since your last sync.
Which two authentication methods does the lecture recommend for GitHub?
Answer: 2) Either paste a Personal Access Token or set up an SSH key.