Since R version 2.12, there’s a droplevels()
function.
levels(droplevels(subdf$letters))
More Related Contents:
- Reshaping data.frame from wide to long format
- How to sum a variable by group
- How do I make a list of data frames?
- Dynamically select data frame columns using $ and a character value
- The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe
- Numbering rows within groups in a data frame
- Simultaneously merge multiple data.frames in a list
- Split data frame string column into multiple columns
- Calculate the mean by group
- Count number of rows within each group
- Quickly reading very large tables as dataframes
- Remove rows with all or some NAs (missing values) in data.frame
- Split data.frame based on levels of a factor into new data.frames
- Combine a list of data frames into one data frame by row
- Subset data frame based on number of rows per group
- Combine two data frames by rows (rbind) when they have different sets of columns
- Counting unique / distinct values by group in a data frame
- Pass a data.frame column name to a function
- Drop data frame columns by name
- How to split a data frame?
- Why is it not advisable to use attach() in R, and what should I use instead?
- Create an empty data.frame
- Cleaning up factor levels (collapsing multiple levels/labels)
- How to plot all the columns of a data frame in R
- Convert data.frame column format from character to factor
- Combine two or more columns in a dataframe into a new column with a new name
- Confusion between factor levels and factor labels
- Dollar sign before a variable
- Re-ordering factor levels in data frame [duplicate]
- Convert list to data frame while keeping list-element names