dropdata: Drop Observations from a Data.frame

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/regr.R

Description

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

Usage

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

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

Value

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

Note

Ordinary subsetting by [...,...] drops attributes like doc or tit. Furthermore, the convenient way to drop rows or columns by giving negative indices to [...,...] cannot be used with names of rows or columns.

Author(s)

Werner A. Stahel, ETH Zurich

See Also

subset

Examples

1
2
3
4
5
6
7
8
9
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)

regr0 documentation built on May 31, 2017, 2:26 a.m.