4 ms·
Summary: author shows three ways to extract numeric-only columns from a dataframe, 1. a naive loop, 2. using apply(), and 3. using idiomatic sapply(). Only meth
by jimmyvalmer 7y ago
Summary: author shows three ways to extract numeric-only columns from a
dataframe, 1. a naive loop, 2. using apply(), and 3. using idiomatic sapply().
Only methods 1 and 3 work as apply() assumes singly-typed vectors (and
dataframes can have mixed types). Author is frustrated because 1. there
are too many ways to do simple extractions and 2. using apply() is a prime
example of "a little knowledge is a dangerous thing."
Verbosity is an existential threat.