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.
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.