makeDataFrame: Initialize data.frame in a convenient way.

View source: R/makeDataFrame.R

makeDataFrameR Documentation

Initialize data.frame in a convenient way.

Description

Initialize data.frame in a convenient way.

Usage

makeDataFrame(
  nrow,
  ncol,
  col.types,
  init,
  row.names = NULL,
  col.names = sprintf("V%i", seq_len(ncol))
)

Arguments

nrow

[integer(1)]
Nubmer of rows.

ncol

[integer(1)]
Number of columns.

col.types

[character(ncol) | character(1)]
Data types of columns. If you only pass one type, it will be replicated. Supported are all atomic modes also supported by vector, i.e. all common data frame types except factors.

init

[any]
Scalar object to initialize all elements of the data.frame. You do not need to specify col.types if you pass this.

row.names

[character | integer | NULL]
Row names. Default is NULL.

col.names

[character | integer]
Column names. Default is “V1”, “V2”, and so on.

Examples

print(makeDataFrame(3, 2, init = 7))
print(makeDataFrame(3, 2, "logical"))
print(makeDataFrame(3, 2, c("logical", "numeric")))

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.

Related to makeDataFrame in BBmisc...