adjust.dataset | R Documentation |
Add new columns to data.frame, fill them with specified value and trim columns which are absent in col.names.
adjust.dataset(df, col.names, value = 0)
df |
data.frame which should be modified. |
col.names |
columns names which should be present in output data.frame. |
value |
value which should fill missing columns. |
this function is useful in adjust features of one dataset (e.g. test set) to another one (e.g. training set). Because some models need exactly the same features in the same order in test set as in training set to make correct prediction.
data.frame containing only specified columns in that order. Previously missing columns will be fill with the specified value.
df <- data.frame(A=1:10, B=11:20, C=21:30)
adjust.dataset(df, c("A","F","B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.