Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

randomise

Order the rows of a data randomly


Description

Takes in data and seed, and returns the data with randomly ordered observations

Usage

randomise(data, seed = NULL)

Arguments

data

a matrix, data.frame or data.table

seed

an integer value

Details

Some of the modeling algorithms pick top p percent of the observations for training the model, which could lead to skewed predictions. This function solves that problem by randomly ordering the observations so that the response variable has more or less the same distribution even if the algorithms don't pick training observations randomly.

Value

data of same class as input with randomly ordered observations

Author(s)

Akash Jain

See Also

Examples

# A 'data.frame'
df <- data.frame(x = c(1, 2, 3, 4, 5), y = c('a', 'b', 'c', 'd', 'e'))

# Change the order of the observations randomly
dfRan <- randomise(data = df)
dfRan <- randomise(data = df, seed = 150)

StatMeasures

Easy Data Manipulation, Data Quality and Statistical Checks

v1.0
GPL-2
Authors
Akash Jain
Initial release
2015-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.