n_obs {brolgar} | R Documentation |
Return the number of observations
Description
Returns the number of observations of a vector or data.frame. It uses
vctrs::vec_size()
under the hood.
Usage
n_obs(x, names = TRUE)
Arguments
x |
vector or data.frame |
names |
logical; If TRUE the result is a named vector named "n_obs", else it is just the number of observations. |
Value
number of observations
Note
You cannot use n_obs
with features
counting the key variable like
so - features(heights, country, n_obs)
. Instead, use any other variable.
Examples
n_obs(iris)
n_obs(1:10)
add_n_obs(heights)
heights %>%
features(height_cm, n_obs) # can be any variable except id, the key.
[Package brolgar version 1.0.1 Index]