New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsetting data frames by names also possible for rows #295

gosianow opened this Issue Sep 19, 2017 · 1 comment


None yet
3 participants

gosianow commented Sep 19, 2017

In Programming with R, Addressing Data, there are three ways of addressing data frames in R:

  • By index (slicing),
  • By logical vector,
  • By name (columns only).

Using $ works only for columns, but subsetting by names using [] is possible for both rows and columns, for example, head(dat['2', c('Age', 'Gender')]). So maybe the last point should be rephrased to something like this: "By name ($ for columns only)"? And an example of subsetting by row names could be added?

The order of the content is:

  • Addressing by Index
  • Addressing by Name
  • Logical Indexing

Maybe it could be put in the same order as the first list, or the first list could be reordered.

The function names is presented. Maybe it is worth presenting also colnames and rownames?


This comment has been minimized.


katrinleinweber commented Feb 12, 2018

Hello @gosianow! Thanks for taking the time to submit this suggestion :-)

I agree about presenting also colnames and rownames, see #315. Could I interest you in submitting a PR with that change, and a second one for the subsetting?

fmichonneau added a commit that referenced this issue Jun 19, 2018

Merge pull request #295 from carpentries/update-urls
update URLs to reflect consolidation to carpentries organization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment