adjust.dataset: Adjust dataset

View source: R/functions.R

adjust.datasetR Documentation

Adjust dataset

Description

Add new columns to data.frame, fill them with specified value and trim columns which are absent in col.names.

Usage

adjust.dataset(df, col.names, value = 0)

Arguments

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.

Details

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.

Value

data.frame containing only specified columns in that order. Previously missing columns will be fill with the specified value.

Examples

df <- data.frame(A=1:10, B=11:20, C=21:30)
adjust.dataset(df, c("A","F","B"))

DrrDom/pfpp documentation built on April 17, 2024, 10:24 a.m.