ez.header: create a header for a data frame; also create the data frame

View source: R/frame.R

ez.headerR Documentation

create a header for a data frame; also create the data frame

Description

wrapper of data.frame(), commonly use together with ez.append

Usage

ez.header(..., cols = NULL, stringsAsFactors = FALSE)

Arguments

...

e.g., col1=character(n), 'col2'=numeric(n) where n defaults to 0, represents n of rows in the data frame, ” around col name is optional

cols

optional (default=NULL), specify only if massively assign col names (i.e. header), see example

stringsAsFactors

defaults to FALSE (data.frame() defaults to TRUE)

Value

returns an (empty) df with specified col names

See Also

ez.append

Examples

postdoc=ez.header(name=character(),'salary'=numeric())
postdoc=ez.header(cols=c('name','salary'))  # <--note that 'name','salary' data type is logical in this usage

# typical use:
results = ez.header(variable=character(),class=character(),n=numeric())
vars=colnames(x)
for (var in vars) {
    var=
    cls=
    n=
    results = ez.append(results,list(var,cls,n))
}
ez.savex(results,'x.xlsx')

jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.