Learn R Programming

colorrepel (version 0.4.3)

by_cluster_sampling: Balanced downsampling of matrix/data.frame based on cluster assignment vector

Description

Balanced downsampling of matrix/data.frame based on cluster assignment vector

Usage

by_cluster_sampling(df, vec, frac, seed = 34)

Value

list with new downsampled matrix/data.frame and id vector

Arguments

df

expression matrix or data.frame

vec

vector of ids

frac

fraction 0-1 to downsample to

seed

sampling randomization seed

Examples

Run this code
res <- by_cluster_sampling(data.frame(y = c(1, 2, 3, 4, 5, 6)),
  vec = c(1, 2, 1, 2, 1, 2), frac = 0.5
)

Run the code above in your browser using DataLab