dfTemplate | R Documentation |
This function handles the creation of data frames based on intuitive parameters. It was originally designed to make row binding easier when columns differs among data frame by creating data frames with the same columns.
dfTemplate(cols, nrows = 1, col_classes = NULL, fill = NA) dfTemplateMatch(x, y, yonly = FALSE, order = FALSE, ...)
cols |
either a number of column or a vector of character used as columns names of the data frame to be returned. |
nrows |
row number. |
col_classes |
vector of column classes for the desired data frame.
By default, the class is determined by |
fill |
character or number used to fill out the columns. Default is |
x |
a data frame. |
y |
a data frame or a vector of strings use to specifies column names to be included in the data frame. |
yonly |
a logical. Should only |
order |
a logical. Should column of the output data frame be ordered
according to the template. Not that if there are more columns in |
... |
further arguments to be passed to |
Returns a data frame with the desired characteristics.
dfTemplateMatch()
: Returns a data frame that includes all columns specifies in y
.
dfTemplate(5, 2) dfTemplate(5, 2, col_classes = "character") dfA <- data.frame(col1 = c(1, 2), col2 = LETTERS[1:2]) dfB <- data.frame(col4 = c(1, 2), col2 = LETTERS[1:2]) dfTemplateMatch(dfA, c("col4", "col2")) dfTemplateMatch(dfA, c("col4", "col2"), yonly = TRUE) dfTemplateMatch(dfA, dfB, yonly = TRUE, order = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.