knn_df: knns function from class that takes a data.frame and a...

Description Usage Arguments Details Value Examples

View source: R/knn_df.R

Description

This function is a simple wrapper that lets you work with class::knns() while using data.frame, thus allowing you to stay with the same format.

Usage

1

Arguments

data

A data.frame.

formula

an object of class "formula" (or one that can be coerced to that class)

split

variable that was used to split data.frame into training and test set.

...

Additional arguments to be passed to the knn function.

Details

It allows for the use of the formula expression from base stats, where the lhs is the factor of the true. The split variable must be logical.

Value

an object of class "knn".

Examples

1
2
3
4
data <- iris
data$split <- as.logical(sample(0:1, nrow(data), TRUE))

knn_df(data, Species ~ Sepal.Length + Sepal.Width, split, k = 5, prob = TRUE)

GarrettMooney/moonmisc documentation built on Oct. 19, 2019, 7:51 p.m.