Sampling one row from a nested dataframe. The sampling could be done either randomly or a specific row could be indicated.
Source:R/samplesubset.R
sample_row.Rd
The default type of return is list
, which will return the data frame
as the first item, and grouping variables as other items in the list.
If the return type is indicated as df
, this function can also return
a dataframe with the nested data, and grouping variables will be
transformed as columns with identical values.
Arguments
- nest_df
The nested dataframe to be sampled from. The right-most column must be a dataframe type with name 'data'.
- index
Optional. The index of the dataframe to be sampled from. If no index is provided, a random subset will be returned.
- type
Optional. 'list' or 'df'. The type of return data structure. List is the default.