apply_levels: Converts the column factor levels in 'df' to those in...

Description Usage Arguments Value


Each column in the result is a factor with the values of df and the levels of df_reference. This means that if there are levels in df_to_change that are not in df_reference, NAs will be introduced. The main use of this function is in classifier problems, where the training and the test set need to have equal factors. To work, all names(df_reference) need to be


apply_levels(df, df_reference)



The df that is to be releveled


A reference df, which column levels will be applied to df if that column is a factor


A data.frame where all factor's levels where changed. Through applying new levels, NAs could have been introduced

Search within the crtests package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.