subset_data: Truncate a data frame to create a subset of the data

Description Usage Arguments Value Examples

View source: R/subset_data.R

Description

This function extracts a subset data frame based on a given set of rules. Can subset data based on ranges of: time, oxygen, row number, or proportion. To subset by 'time' and by 'o2', the function assumes time is in the first column, and oxygen in the second column. To subset by 'proportion', the function calculates proportion data from the oxygen column. This function can subset any data frame by 'row'.

Usage

1
subset_data(x, from, to, by = "time")

Arguments

x

data frame. The data to subset.

from

numeric. Defines the lower bound(s) of the data frame to subset. Subsetting is based on the argument: by.

to

numeric. Defines the upper bound(s) of the data frame to subset. Subsetting is based on the argument: by.

by

string. "time", "row", "o2" or "proportion".

Value

A data.table object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Subset by time:
x <- subset_data(squid.rd, from = 2000, to = 4000, by = "time")
plot(x)
subset_data(flowthrough.rd, from = 50, to = 600, by = "time")

# Subset by O_2:
subset_data(sardine.rd, from = 94, to = 91, by = "o2")

# Subset by proportion:
subset_data(sardine.rd, from = 0.8, to = 0.4, by = "proportion")

# Subset by row:
subset_data(flowthrough.rd, from = 10, to = 750, by = "row")

januarharianto/respR documentation built on July 30, 2018, 11:18 p.m.