From 049700c087ccbda19689ceec290effdb88993c31 Mon Sep 17 00:00:00 2001 From: Kevin Cazelles Date: Fri, 5 Jun 2020 16:06:11 -0400 Subject: [PATCH] :bookmark: bump minor --- DESCRIPTION | 4 ++-- NEWS.md | 6 +++--- R/dfTemplate.R | 8 ++++---- man/dfTemplate.Rd | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a308096..cbaa3a8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: inSilecoMisc Title: inSileco Miscellaneous Functions -Date: 2020-04-10 -Version: 0.4.0.9000 +Date: 2020-06-05 +Version: 0.5.0 Authors@R: c( person("Kevin", "Cazelles", email = "kevin.cazelles@gmail.com", comment = c(ORCID = "0000-0001-6619-9874"), role = c("aut", "cre")), person("David", "Beauchesne", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 03cd522..abbfe29 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ -# inSilecoMisc (devel) +# inSilecoMisc 0.5.0 -* `dfTemplateMatch()` gains one argument `order` to order column of the output -dataframe according to the template. +* `dfTemplateMatch()` gains an argument `order` to order column of the output +data frame according to the template (see #20). * add `stopwatch()` and `timer()`. * add `seqRg()` that generates a regular sequence based on the range of a vector. * add `seqRow()` and ``seqCol()` that generate a regular sequences based on the number of rows and columns (respectively) of a data frame (or a matrix). diff --git a/R/dfTemplate.R b/R/dfTemplate.R index 0568a18..1329e50 100644 --- a/R/dfTemplate.R +++ b/R/dfTemplate.R @@ -12,8 +12,7 @@ #' By default, the class is determined by `fill`. #' @param fill character or number used to fill out the columns. Default is `NA`. #' @param x a data frame. -#' @param y data frame or a vector of strings that includes part of or all of -#'the column names of the data frame to be output. +#' @param y a data frame or a vector of strings use to specifies column names to be included in the data frame. #' @param yonly a logical. Should only `y` (or the `names(y)`) be used for the #' data frame to be returned? Default is set to `FALSE` meaning that both the #' names of `x` and the names of `y` are used. @@ -35,9 +34,10 @@ #' 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, c("col4", "col2"), yonly = TRUE, order = TRUE) +#' dfTemplateMatch(dfA, dfB, yonly = TRUE, order = TRUE) dfTemplate <- function(cols, nrows = 1, col_classes = NULL, fill = NA) { @@ -72,7 +72,7 @@ dfTemplate <- function(cols, nrows = 1, col_classes = NULL, fill = NA) { } -#' @describeIn dfTemplate Returns a data frame that matches names in `y`. +#' @describeIn dfTemplate Returns a data frame that includes all columns specifies in `y`. #' @export dfTemplateMatch <- function(x, y, yonly = FALSE, order = FALSE, ...) { diff --git a/man/dfTemplate.Rd b/man/dfTemplate.Rd index a5cf86c..6cfbe3d 100644 --- a/man/dfTemplate.Rd +++ b/man/dfTemplate.Rd @@ -22,8 +22,7 @@ By default, the class is determined by \code{fill}.} \item{x}{a data frame.} -\item{y}{data frame or a vector of strings that includes part of or all of -the column names of the data frame to be output.} +\item{y}{a data frame or a vector of strings use to specifies column names to be included in the data frame.} \item{yonly}{a logical. Should only \code{y} (or the \code{names(y)}) be used for the data frame to be returned? Default is set to \code{FALSE} meaning that both the @@ -47,16 +46,17 @@ columns. } \section{Functions}{ \itemize{ -\item \code{dfTemplateMatch}: Returns a data frame that matches names in \code{y}. +\item \code{dfTemplateMatch}: Returns a data frame that includes all columns specifies in \code{y}. }} \examples{ 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, c("col4", "col2"), yonly = TRUE, order = TRUE) +dfTemplateMatch(dfA, dfB, yonly = TRUE, order = TRUE) } \references{ \url{https://insileco.github.io/2019/02/03/creating-empty-data-frames-with-dftemplate-and-dftemplatematch/}