Rev 2273 | Rev 7313 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{subset}\alias{subset}\alias{subset.default}\alias{subset.data.frame}\title{Subsetting vectors and data frames}\usage{subset(x, ...)subset.default(x, subset)subset.data.frame(x, subset, select)}\arguments{\item{x}{Object to be subsetted}\item{\dots}{How to subset, depends on object}\item{subset}{logical expression}\item{select}{expression, indicating variables to select from adataframe}}\description{For ordinary vectors, the result is simply\code{x[subset & !is.na(subset)]}.For dataframes, the \code{subset} argument works similarly on therows. Note that \code{subset} will be evaluated in the dataframe.The \code{select} argument exists only for dataframes. It works byfirst replacing variable names in the selection expression with thecorresponding column numbers in the dataframe and then using theresulting integer vector to index the columns. This allows the useof the standard indexing conventions so that e.g. ranges ofvariables can be specified easily.}\value{Selected rows and columns of the object \code{x}.}\author{Peter Dalgaard}\seealso{\code{\link{[}},\code{\link{transform}}}\examples{data(airquality)subset(airquality, Temp > 80, select = c(Ozone, Temp))subset(airquality, Day == 1, select = -Temp)subset(airquality, select = Ozone:Wind)attach(airquality)subset(Ozone, Temp > 80)}\keyword{manip}