Skip to content

Commit

Permalink
unCamelCase droplevels, use except= not exclude=
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@52840 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
pd committed Aug 30, 2010
1 parent 7d3b60b commit 6a657e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
cases (e.g. where emulation is used and when \file{file} is not in
the current directory).

\item New function \code{dropLevels()} to remove unused factor levels.
\item New function \code{droplevels()} to remove unused factor levels.

\item \code{system(intern = TRUE)} now gives an error on a
Unix-alike (as well as on Windows) if \code{command} cannot be
Expand Down
10 changes: 5 additions & 5 deletions src/library/base/R/factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ nlevels <- function(x) length(levels(x))
y
}

dropLevels <- function(x, ...) UseMethod("dropLevels")
dropLevels.factor <- function(x, ...) factor(x)
dropLevels.data.frame <- function(x, exclude = NULL, ...)
{
droplevels <- function(x, ...) UseMethod("droplevels")
droplevels.factor <- function(x, ...) factor(x)
droplevels.data.frame <- function(x, except = NULL, ...)
{
ix <- sapply(x, is.factor)
if (!is.null(exclude)) ix[exclude] <- FALSE
if (!is.null(except)) ix[except] <- FALSE
x[ix] <- lapply(x[ix], factor)
x
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
% Copyright 1995-2009 R Core Development Team
% Distributed under GPL 2 or later

\name{dropLevels}
\title{dropLevels}
\alias{dropLevels}
\alias{dropLevels.factor}
\alias{dropLevels.data.frame}
\name{droplevels}
\title{droplevels}
\alias{droplevels}
\alias{droplevels.factor}
\alias{droplevels.data.frame}
\concept{categorical variable}
\concept{enumerated type}
\concept{category}
\description{
The function \code{dropLevels} is used to drop unused levels from a factor or, more commonly, from factors in a data frame.
The function \code{droplevels} is used to drop unused levels from a factor or, more commonly, from factors in a data frame.
}
\usage{
\S3method{dropLevels}{factor}(x,\dots)
\S3method{dropLevels}{data.frame}(x, exclude, \dots)
\S3method{droplevels}{factor}(x,\dots)
\S3method{droplevels}{data.frame}(x, except, \dots)
}
\arguments{
\item{x}{an object from which to drop unused factor levels.}
\item{\dots}{further arguments passed to methods}
\item{exclude}{indices of columns from which \emph{not} to drop levels}
\item{except}{indices of columns from which \emph{not} to drop levels}
}
\value{
\code{dropLevels} returns an object of the same class as \code{x}}
\code{droplevels} returns an object of the same class as \code{x}}
\details{
The method for class \code{"factor"} is essentially equivalent to \code{factor(x)}.

Expand All @@ -35,7 +35,7 @@
in a data frame contains only elements from a reduced level set
after subsetting. (Notice that subsetting does \emph{not} in general
drop unused levels). By default, levels are dropped from all factors
in a data frame, but the \code{exclude} argument allows you to
in a data frame, but the \code{except} argument allows you to
specify columns for which this is undesirable.
}

Expand All @@ -50,7 +50,7 @@
aq <- transform(airquality, Month=factor(Month,labels=month.abb[5:9]))
aq <- subset(aq, Month != "Jul")
table(aq$Month)
table(dropLevels(aq)$Month)
table(droplevels(aq)$Month)
}
\keyword{category}
\keyword{NA}
2 changes: 1 addition & 1 deletion tests/reg-tests-2.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -3175,7 +3175,7 @@ Error in `[.data.frame`(x, 1, c("a", "c")) : undefined columns selected
[1] $<- Math Ops Summary [
[6] [<- [[ [[<- aggregate anyDuplicated
[11] as.data.frame as.list as.matrix by cbind
[16] dim dimnames dimnames<- dropLevels duplicated
[16] dim dimnames dimnames<- droplevels duplicated
[21] edit format formula head is.na
[26] mean merge na.exclude na.omit plot
[31] print prompt rbind row.names row.names<-
Expand Down

0 comments on commit 6a657e7

Please sign in to comment.