Subsetting

Mini-Lecture 4

Ben Baumer

Smith College

2024-09-12

Slack review

More practice

I think I just need more practice with GitHub.

Now that I’m taking the time to really learn how it works (instead of just viewing it as an obstacle to be overcome in group projects), I’m starting to understand why certain errors happen.

  • You’re ready
  • It’s time

GitHub credentials

gitcreds::gitcreds_get()
<gitcreds>
  protocol: NA
  host    : NA
  username: NA
  password: <-- hidden -->
usethis::gh_token_help()
usethis::git_sitrep()

Pull requests

I’m also a little confused about the reasoning behind pull requests. I know they’re useful when you don’t have access to change a repository, but can they be used when you do have editing power?

  • Yes. Pull requests are always from branch-to-branch
    • not always repo-to-repo
  • Code review: gives someone else a chance to review your contribution
  • This is way that things are done IRL

Helper functions

My push/pull buttons are still greyed out despite my attempt at troubleshooting using the text. Any help?

  • It’s because you’re on a branch
  • Everything that happens in RStudio or through usethis are wrappers around git commands
  • The “push” button = git push [origin main]
  • But you’re not on the main branch. So try git push origin <branchname>
  • same as usethis::pr_push(branchname = "<brachname>")

Being ahead

how worried I should be about the “you are _ commits ahead of master” messages that I always seem to have even after I pull.

  • You probably want to push

Frustration

Somehow I had trouble or errors for each exercise, which made me very frustrated. I am sure I will face more errors during classes. But after trying and using Github for several times will make me better at Github. Hopefully.

  • Hang in there!

“GitHub is the worst form of version control except for all those other forms that have been tried”

–Me paraphrasing Winston Churchill quoting someone else

Command line

I also want to practice more git execution using the terminal

  • More on that later

Console vs. Terminal

Understanding the different components of GitHub RStudio, such as Console and Terminal, and how they are related to each other?

Learning Lab

I also completed the “Introduction to Github” from Github’s Learning Lab, which was extremely helpful- I highly recommend!

https://lab.github.com/githubtraining/introduction-to-github

  • Thanks!

Subsetting

Operators

Use:

  • dplyr::filter()
  • dplyr::select()
  • dplyr::pull()
  • purrr::pluck()

Avoid:

  • subset()
  • rvest::pluck()
  • magrittr::extract()
  • magrittr::extract2()

Today: Old-school, base R operators: [, [[, $

Train metaphor

Pepper shaker

x

x[1]

x[[1]]

x[[1]][[1]]

Now

Work on

  • Lab #4: Subsetting

  • Reading quiz on Moodle by Monday night at 11:59 pm