to_data_frame: Convert data to data.frame

View source: R/utils.R

to_data_frameR Documentation

Convert data to data.frame

Description

Given an object convert it to data.frame.

Usage

to_data_frame(x, remove_na = FALSE)

Arguments

x

(any) The object to be converted to data.frame.

remove_na

(logical(1)) Should NA values be removed?. FALSE by default.

Details

The following rules are applied when converting the object to matrix depending the object's type:

  • numeric vector: It is converted to a one column data.frame.

  • character, logical and factor vectors: All of these are considered to be categorical variables and therefore a coerced to factor in a one column data.frame.

  • matrix: If it is character, logical or factor are included in the same way as described for vectors and only coerced to data.frame for numeric matrices.

For all the columns a name is assigned if they has no one.

Value

A data.frame.

Examples

## Not run: 
to_data_frame(iris)
to_data_frame(1:10)
to_data_frame(c("a", "b", "c"))
to_data_frame(data.frame(a = c("a", "b"), b = c("c", "d")))

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.