makeDataFrame {BBmisc}R 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))
##   V1 V2
## 1  7  7
## 2  7  7
## 3  7  7
print(makeDataFrame(3, 2, "logical"))
##      V1    V2
## 1 FALSE FALSE
## 2 FALSE FALSE
## 3 FALSE FALSE
print(makeDataFrame(3, 2, c("logical", "numeric")))
##      V1 V2
## 1 FALSE  0
## 2 FALSE  0
## 3 FALSE  0

[Package BBmisc version 1.7 Index]