select_random_subset: Select Random

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Select a random subset of time series from a dataset by using unique ID subset. Optionally, a minimum number of observation for the individual IDs can be provided.

Usage

1
2
select_random_subset(in.file, ntraj, col.uniqID, col.time,
  min.obs = NULL, col.whatokeep = NULL, out.file = NULL)

Arguments

in.file

A character or a variable for the current environment. If a character, a path to a .csv file is expected.

ntraj

Numeric. How many unique IDs to extract?

col.uniqID

Character. Name of the column with unique IDs.

col.time

Character. Name of the column with time.

min.obs

Optional numeric. Minimum number of observations of an ID.

col.whatokeep

Optional character. Name of the columns to be returned in the output. If NULL returns all columns. Columns with uniqID and time are always returned.

out.file

Optional character. If provided the output is saved as a .csv file to the path indicated by out.file. Otherwise, the new dataset is returned.

Value

A data.table with the columns indicated in col.whatokeep.

Examples

1
2
3
4
5
6
7
8
# Simulate 10 phase-shifted sinusoids with 3 different level of noises
# ("experimental conditions", first grouping).
x <- multi_sims(type = "ps", noises = c(0.2,0.4), n = 10)
plot_sim(x)

# Read/export 5 random TS from/in environment
x[, uniqID := paste(noise, variable, sep ="_")]
x_subset <- select_random_subset(in.file=x, ntraj=5, col.uniqID="uniqID", col.time="Time")

majpark21/TSexploreR documentation built on Oct. 16, 2019, 2:46 p.m.