remove {dformula}R Documentation

Remove a subset

Description

Selects the row and the varaibles to remove by specifing a condition using a formula.

Usage

remove(from, formula = .~., na.remove = FALSE, ...)

Arguments

from

a data.frame object with variables

formula

a formula indicating the operation to create new varibles. Look at the detail section for explanantion.

na.remove

a logical value indicating whether NA values should be removed.

...

further arguments

Details

The formula is composed of two part:

column_names ~ rows_conditions

the left-hand side are the names of the column to remove, and the right-hand the operation to remove the rows, using the I() function.

For example:

column_names1 + column_names2 ~ I(column_names1 == "a") + I(column_names2 > 4)

first the row are selected to be removed if the observation in the column_names1 are equal to a and if the observation in the column_names2 are biggers than 4, then the column_names1 and column_names2 are removed and the other varaibles are returned.

If na.remove is set to TRUE, after the subsetting the observations with missing are removed.

Value

Returns a data.frame object without the selected elements.

Author(s)

Alessio Serafini

Examples


data("airquality")
dt <- airquality

head(remove(from = dt, formula = .~ I(Ozone > 10)))
head(remove(from = dt, formula = .~ I(Ozone > 10), na.remove = TRUE))
head(remove(from = dt, formula = Ozone ~ .))

head(remove(from = dt, formula = Ozone~ I(Ozone > 10)))
head(remove(from = dt, formula = Ozone + Wind~ I(Ozone > 10)))

head(remove(from = dt, formula = Ozone + . ~ I(Ozone > 10)))
head(remove(from = dt, formula = Ozone + NULL ~ I(Ozone > 10)))



[Package dformula version 1.0 Index]