Skip to content
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 episode: dropping levels of a factor #741

Open
gtitcomb opened this issue Sep 15, 2021 · 1 comment
Open

Subsetting data episode: dropping levels of a factor #741

gtitcomb opened this issue Sep 15, 2021 · 1 comment
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson

Comments

@gtitcomb
Copy link

In this episode, participants are shown various examples of subsetting a factor in the "Factor subsetting" section.
One of the last comments is "Skipping elements will not remove the level even if no more of that category exists in the factor:"
f[-3]
I felt that this comment begs the question: How do we drop the levels of a factor?
Perhaps a line of code stating that levels can be dropped using:
droplevels(f[-3])
would help clear this question up, hopefully without introducing too much additional content.

I'm not sure how widely-used droplevels is now that dplyr is the preferred way to manipulate/group data, but perhaps it's useful if a user is importing some files with empty levels, or even if someone tries to write a loop by iterating over levels of a factor.

Alternatively, the comment about skipping elements of the level could be removed if it is not revisited later in the lesson or expanded upon here.

@jcoliver
Copy link
Contributor

Thanks, @gtitcomb . A brief point about the functionality of droplevels() might be most appropriate as a Tip immediately following the f[-3] output.

@jcoliver jcoliver added good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson labels Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors type:enhancement Propose enhancement to the lesson
Projects
None yet
Development

No branches or pull requests

2 participants