split_into_n_columns: Split data into n columns.

split_into_n_columnsR Documentation

Split data into n columns.

Description

Reshapes the data to a wider structure for easy use in documents. Pads empty lines between and can include their rownames and colnames as well. Outputs a character matrix.

Usage

split_into_n_columns(
  data,
  split_times,
  pad_rows = T,
  include_rownames = T,
  rownames_var = "name",
  include_colnames = T
)

Arguments

data

(data.frame, matrix, or something coercible into a matrix) The data to reshape.

split_times

(whole number scalar) How many times to split the rows.

include_colnames

(logical) Whether to include the column names in the output. Defaults to TRUE.

pad_columns

(logical) Whether to pad empty columns to the data if the data and column dimensions do fit divide into a whole number. Defaults to TRUE.

rownames_colnames

(character scalar) If adding colnames in rows, which rownames should these be given? Defaults to "name".

Examples

df = data.frame(small = letters[1:6], big = LETTERS[1:6], stringsAsFactors = F)
split_into_n_columns(df, 2) #ok
split_into_n_columns(df, 3) #ok
split_into_n_columns(df, 4) #stupid but no error!

Deleetdk/kirkegaard documentation built on April 1, 2024, 2:23 a.m.