knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Loading libraries

library(Laurae2)

Create a data.frame using RC format

Functions:

Libraries required :

It is possible to create a data.frame using the RC format. It requires a list as values or any vector.

# Create default named [5, 5] data.frame
data.frame.rc(0, nrow = 5, ncol = 5)

# Create named [5, 5] data.frame
data.frame.rc(0, nrow = 5, ncol = 5, column_names = c("car", "minicooper", "truck", "porsche", "speedo"))

# Create named [5, 5] data.frame with values
data.frame.rc(list(1:5,
                   c(TRUE, FALSE, TRUE, FALSE, TRUE),
                   5:1,
                   c("has", "not", "has", "not", "has"),
                   c(150L, 200L, 250L, 300L, 350L)),
              nrow = 5, ncol = 5)

# Create named [5, 5] data.frame with named values
data.frame.rc(list(1:5,
                   c(TRUE, FALSE, TRUE, FALSE, TRUE),
                   5:1,
                   c("has", "not", "has", "not", "has"),
                   c(150L, 200L, 250L, 300L, 350L)),
              nrow = 5, ncol = 5, column_names = c("car", "minicooper", "truck", "porsche", "speedo"))

# Create named [5, 5] data.frame with values
data.frame.rc(list(car = 1:5,
                   minicooper = c(TRUE, FALSE, TRUE, FALSE, TRUE),
                   truck = 5:1,
                   porsche = c("has", "not", "has", "not", "has"),
                   speedo = c(150L, 200L, 250L, 300L, 350L)),
              nrow = 5, ncol = 5)


Laurae2/Laurae2 documentation built on May 18, 2019, 11:27 p.m.