extract_numeric_columns: extract_numeric_columns

Description Usage Arguments Value Errors Examples

View source: R/extract_numeric_columns.R

Description

This function returns all of the columns of the given dataset whose values are numeric or have a meaningfull numerical equivalent. If isCSV is TRUE, then dataset is taken a string depicitng the name of a CSV file. with_bool specifies if booleans are taken as numeric as well.

Usage

1
2
extract_numeric_columns(dataset, isCSV = FALSE, columns = NULL,
  row_names = FALSE, with_bool = FALSE, header = TRUE)

Arguments

dataset

A DataFrame of Data.Table object whose columns will be inspected for numeric values. If isCSV is TRUE, then dataset is the name of the CSV file to inspect.

isCSV

bool. If TRUE, the dataset will be read from the CSV file depicted in dataset.

columns

vector list of column names to coerce which columns the analysis will apply to. The given columns that do not pass the numeric test will be returned as NAs. If default extract_numeric_columns will apply the numeric test to all columns and return only the ones that pass it.

row_names

bool or integer. Only applied when isCSV is TRUE. If TRUE, the dataset will be read and returned with their row names. If FALSE, the dataset won't be read with row names. If row_names is an integer, then that index will be used consider the row names column.

with_bool

bool. Specifies whether we consider booleans as numeric values.

header

bool. Same Parameters as that in read.csv. Specifies if the CSV being read contains headers in the first row. TRUE by default.

Value

This function returns a Data Frame object, with row names given based on the row_names argument. It includes all the columns of the given dataset whose elements are all numeric or have a meaningful numerical equivalent.

Errors

extract_numeric_columns won't be able to detect numeric values in columns of data type factor. If a numeric column is being read from a csv as factor by this function, then the dataset must be given as data table or data frame object (isCSV = FALSE).

Examples

1
2
3
4
5
6
7
## Not run: 
extract_numeric_columns(mtcars)
extract_numeric_columns(mtcars, columns = c("mpg", "cyl"))
extract_numeric_columns("test_data_1.csv", isCSV = TRUE)
extract_numeric_columns("test_data_2.csv", isCSV = TRUE, row_names = TRUE, with_bool = TRUE)

## End(Not run)

ronybsulca/numericColumns documentation built on May 29, 2019, 1:19 p.m.