dt.remove.variables {DTwrappers}R Documentation

dt.remove.variables

Description

A function to remove selected columns from a data.frame or data.table object.

Usage

dt.remove.variables(
  dt.name,
  the.variables,
  return.as = "result",
  envir = .GlobalEnv,
  ...
)

Arguments

dt.name

a character value specifying the name of a data.frame or data.table object to select data from. A variable called dat should be referred to with dt.name = "dat" when using the function.

the.variables

A character or numeric vector specifying the variables that we want to remove. For character vectors, only values that exist in the names of the data will be used. For numeric vectors, only the values of unique(floor(sorting.variables)) that are in 1:ncol() of your data will be used. Then these indices will be used to select column names from the data.

return.as

a character value specifying what output should be returned. return.as = "result" provides the updated data. return.as = "code" provides a data.table coding statement. return.as = "all" provides a list object including both the resulting output and the code.

envir

a specification of the environment in which the data (referenced by dt.name) exists, with the global environment as the default value.#'

...

additional arguments if required

Value

a 'data.table' object.

Source

DTwrappers::create.dt.statement

DTwrappers::eval.dt.statement

Examples

n <- nrow(iris)
dat <- data.table::as.data.table(x = iris[sample(x = 1:n, size = n, replace = FALSE),])
dt.remove.variables(dt.name = "dat", the.variables = c("Category", "setosa_sl_below_5"),
return.as = "all")



[Package DTwrappers version 0.0.2 Index]