nsubset: Subset according to frequency of a column

Description Usage Arguments Value Author(s) Examples

Description

Subset an object based on the frequency of a column (factor or not).

Usage

1
2
nsubset(x, col, n, sign = c(">=", "<=", ">", "<", "=="), select,
  drop = FALSE)

Arguments

x

object to be subsetted (e.g. data.frame, matrix, Spatial*DataFrame, etc.).

col

name of the column which stores the grouping factor (without quotes).

n

the reference number for the frequency of the grouping factor (must be a numeric of length 1).

sign

any comparison sign (>= by default, <=, >, <, or ==).

select

expression, indicating columns to select (either name(s) without quote or numeric indicating the column number(s)).

drop

passed on to '[' indexing operator.

Value

A subset of the object (with the same class).

Author(s)

Mathieu Basille basille@ufl.edu

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
bla <- data.frame(value = rnorm(100), group = sample(letters[1:4],
    size = 100, replace = TRUE, prob = (1:4) * 10))
table(bla$group)
bli <- nsubset(bla, group, 25)
table(bli$group)
blo <- nsubset(bla, group, 25, sign = ">", select = 1, drop = TRUE)
head(blo)
length(blo)

basille/basr documentation built on May 11, 2019, 8:32 p.m.