look: Look at data.table subsets

View source: R/look.R

lookR Documentation

Look at data.table subsets

Description

A function to go into the i statement of a data.table that makes random subsets based on a chosen variable

Usage

look(var, n = 1, unique = TRUE)

Arguments

var

A column from a data.table object

n

numeric, How many values are used in subsetting

unique

logical, Randomly choose from a unique set of levels for subsetting. Otherwise, choose from all values despite potential repetition.

Value

A logical vector

Examples

# load some data
library(councilR)
library(data.table)
titanic <- fread("https://raw.githubusercontent.com/Geoyi/Cleaning-Titanic-Data/master/titanic_clean.csv")

# look at a random home.dest
titanic[look(home.dest)] # re-run the this line for a different random pull

# look at a random person
titanic[look(name)]

# look at a random fare and person of that fare
titanic[look(fare)][look(embarked)]


Metropolitan-Council/councilR documentation built on March 30, 2024, 2:43 a.m.