Learn R Programming

relevance (version 2.1)

dropdata: Drop Observations from a Data.frame

Description

Allows for dropping observations (rows) determined by row names or factor levels from a data.frame or matrix.

Usage

dropdata(data, rowid = NULL, incol = "row.names", colid = NULL)

Value

The data.frame or matrix without the dropped observations and/or variables. Attributes are passed on.

Arguments

data

a data.frame of matrix

rowid

vector of character strings identifying the rows to be dropped

incol

name or index of the column used to identify the observations (rows)

colid

vector of character strings identifying the columns to be dropped

Author

Werner A. Stahel, ETH Zurich

See Also

Examples

Run this code
dd <- data.frame(rbind(a=1:3,b=4:6,c=7:9,d=10:12))
dropdata(dd,"b")
dropdata(dd, col="X3")

d1 <- dropdata(dd,"d")
d2 <- dropdata(d1,"b")
naresid(attr(d2,"na.action"),as.matrix(d2))

dropdata(letters, 3:5)

Run the code above in your browser using DataLab