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

datashape

Data shaping tools


Description

Generate a new dataset in a format that is accepted by compare. Dummy variables are created for categorical variables.

Usage

datashape(dataset, y, x, subs)

Arguments

dataset

a dataframe or matrix containing user data.

y

the column number of the outcome variable in dataset d.

x

a vector containing the explanatory or predictor variables of interest. The new data matrix will only contain these variables and the outcome variable.

subs

a vector describing a subset of rows from dataset d to include in the returned data matrix.

Details

This function can be used to prepare a dataset before applying the compare function. The outcome column number must be specified, and specific predictors and observation subsets may be specified. 2-level categorical variables will be converted to binary, while dummy variables will be created for categorical predictors with greater than two levels.

The "datashaped" dataset should be saved to a new object.

Value

This function returns a matrix conforming to the specifications supplied to the datashape function.

Warning

datashape will not function if missing values are present.

@examples ## Preparing the iris dataset data(iris) iris.shaped <- datashape(dataset = iris, y = 4) head(iris.shaped) ## Creating a copy of iris with sepal-related predictors and a subset of observations. iris.sub <- datashape(dataset = iris, y = 4, x = c(1,2), subs = c(1:20, 50:70)) head(iris.sub)


apricom

Tools for the a Priori Comparison of Regression Modelling Strategies

v1.0.0
GPL-2
Authors
Romin Pajouheshnia [aut, cre], Wiebe Pestman [aut], Rolf Groenwold [aut]
Initial release
2015-11-11

We don't support your browser anymore

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