Skip to content
Prev 386031 / 398513 Next

How to assign the same levels to a dataframe column?

Stop using as.factor() and start using factor()? Be explicit about what levels you want and in what order.

As for extracting subsets, use split() and do your subsets on each set of rows with the same level. It will be on you to decide what statistical properties (proportions?) you want to maintain between the full data set and your subset.
On October 20, 2020 6:42:27 AM PDT, Luigi Marongiu <marongiu.luigi at gmail.com> wrote: