From ace3da838e6c48e29205477c408f2929dc1e0ba7 Mon Sep 17 00:00:00 2001 From: Gregory Demin Date: Mon, 6 Jul 2020 14:16:22 +0300 Subject: [PATCH] Fixes for CRAN check --- .Rbuildignore | 1 + .gitignore | 1 + DESCRIPTION | 2 +- NEWS | 2 +- R/add_rows.R | 7 ++++--- R/compute.R | 22 +++++++++------------- R/criteria_functions.R | 14 +++++++------- R/custom_tables.R | 2 +- R/fctr.R | 12 ++++++------ R/selectors.R | 4 +--- R/write_labelled.R | 3 ++- man/add_rows.Rd | 7 ++++--- man/compute.Rd | 22 +++++++++------------- man/criteria.Rd | 14 +++++++------- man/fctr.Rd | 12 ++++++------ man/tables.Rd | 2 +- man/vars.Rd | 4 +--- man/write_labelled_csv.Rd | 2 +- 18 files changed, 63 insertions(+), 70 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index d5e315bc..6bbe9696 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,6 +6,7 @@ \.gitignore \.git ^SupplementaryMaterials +\.SupplementaryMaterials README.MD tests/testthat/data_files tests/testthat/test_write_labels.R diff --git a/.gitignore b/.gitignore index 6b341799..b12fb125 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ doc .RData data_files SupplementaryMaterials +.SupplementaryMaterials diff --git a/DESCRIPTION b/DESCRIPTION index dbf989bb..7332eb06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: expss Type: Package Title: Tables, Labels and Some Useful Functions from Spreadsheets and 'SPSS' Statistics -Version: 0.10.4 +Version: 0.10.5 Maintainer: Gregory Demin Authors@R: c( person("Gregory", "Demin", email = "gdemin@gmail.com", diff --git a/NEWS b/NEWS index 97657885..a3c3f6b2 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -0.10.4 (05.07.2020) +0.10.5 (05.07.2020) ================ * add argument 'default' for 'var_lab' function (issue #60). Thanks to Dan Chaltiel * fixes for new versions of R, htmlTable, huxtable diff --git a/R/add_rows.R b/R/add_rows.R index cc218be2..d0ee4220 100644 --- a/R/add_rows.R +++ b/R/add_rows.R @@ -1,7 +1,8 @@ #' Add rows to data.frame/matrix/table #' -#' \code{add_rows} is similar to \link[base]{rbind} but it handles non-matching -#' column names. \code{\%add_rows\%} is an infix version of \code{add_rows}. +#' Take a sequence of vector, matrix or data-frame arguments and combine by +#' rows. Contrary to \link[base:cbind]{rbind} it handles non-matching column +#' names. \code{\%add_rows\%} is an infix version of \code{add_rows}. #' There is also special method for the results of #' \link{cro}/\link{cro_fun}/\link{tables}/\link{fre}. \code{.add_rows} is #' version for adding rows to default dataset. See \link{default_dataset}. @@ -14,7 +15,7 @@ #' \code{"add"} will combine all columns, \code{"drop"} will leave only common #' columns, \code{"stop"} will raise an error. #' -#' @return See \link[base]{rbind}, \link{cro}, \link{cro_fun}, \link{fre}, \link{tables} +#' @return See \link[base:cbind]{rbind}, \link{cro}, \link{cro_fun}, \link{fre}, \link{tables} #' @export #' #' @examples diff --git a/R/compute.R b/R/compute.R index 1acde9b5..3ed2a9dd 100644 --- a/R/compute.R +++ b/R/compute.R @@ -1,24 +1,20 @@ #' Modify data.frame/modify subset of the data.frame #' #' \itemize{ -#' \item{{\code{compute}}{ evaluates expression \code{expr} in the context of data.frame -#' \code{data} and return original data possibly modified. It works similar to -#' \code{\link[base]{within}} in base R but try to return new variables in order -#' of their occurrence in the expression and make available -#' full-featured \code{\%to\%} and \code{.N} in the expressions. See \link{vars}.}} -#' \item{{\code{calculate}}{ evaluates expression \code{expr} in the context of -#' data.frame \code{data} and return value of the evaluated expression. It works -#' similar to \code{\link[base]{with}} in base R but make available -#' full-featured \code{\%to\%} and \code{.N} in the expressions. See -#' \link{vars}. Function \code{use_labels} is shortcut for \code{calculate} with +#' \item{\code{compute}}{ evaluates expression \code{expr} in the context of data.frame +#' \code{data} and return original data possibly modified.} +#' \item{\code{calculate}}{ evaluates expression \code{expr} in the context of +#' data.frame \code{data} and return value of the evaluated expression. Function \code{use_labels} is shortcut for \code{calculate} with #' argument \code{use_labels} set to \code{TRUE}. When \code{use_labels} is TRUE -#' there is a special shortcut for entire data.frame - \code{..data}.}} -#' \item{{\code{do_if}}{ modifies only rows for which \code{cond} equals to +#' there is a special shortcut for entire data.frame - \code{..data}.} +#' \item{\code{do_if}}{ modifies only rows for which \code{cond} equals to #' TRUE. Other rows remain unchanged. Newly created variables also will have #' values only in rows for which \code{cond} have TRUE. There will be NA's in #' other rows. This function tries to mimic SPSS "DO IF(). ... END IF." -#' statement.}} +#' statement.} #' } +#' Full-featured \code{\%to\%} is available in the expressions for addressing +#' range of variables. #' There is a special constant \code{.N} which equals to number of cases in #' \code{data} for usage in expression inside \code{compute}/\code{calculate}. #' Inside \code{do_if} \code{.N} gives number of rows which will be affected by diff --git a/R/criteria_functions.R b/R/criteria_functions.R index a28dd156..1d87d459 100644 --- a/R/criteria_functions.R +++ b/R/criteria_functions.R @@ -19,15 +19,15 @@ #' equals to maximum or minimum.} #' \item{\code{'contains'}}{ searches for the pattern in the strings. By default, #' it works with fixed patterns rather than regular expressions. For details -#' about its arguments see \link[base]{grepl}} +#' about its arguments see \link[base:grep]{grepl}} #' \item{\code{'like'}}{ searches for the Excel-style pattern in the strings. You #' can use wildcards: '*' means any number of symbols, '?' means single symbol. #' Case insensitive.} #' \item{\code{'fixed'}}{ alias for contains.} #' \item{\code{'perl'}}{ such as \code{'contains'} but the pattern is perl-compatible -#' regular expression (\code{'perl = TRUE'}). For details see \link[base]{grepl}} +#' regular expression (\code{'perl = TRUE'}). For details see \link[base:grep]{grepl}} #' \item{\code{'regex'}}{ use POSIX 1003.2 extended regular expressions -#' (\code{'fixed = FALSE'}). For details see \link[base]{grepl}} +#' (\code{'fixed = FALSE'}). For details see \link[base:grep]{grepl}} #' \item{\code{'has_label'}}{ searches values which have supplied label(-s). We #' can used criteria as an argument for 'has_label'.} #' \item{\code{'to'}}{ returns function which gives TRUE for all elements of @@ -56,10 +56,10 @@ #' @param pattern character string containing a regular expression (or character #' string for \code{'fixed'}) to be matched in the given character vector. #' Coerced by as.character to a character string if possible. -#' @param perl logical see \link[base]{grepl} -#' @param fixed logical see \link[base]{grepl} -#' @param ignore.case logical see \link[base]{grepl} -#' @param useBytes logical see \link[base]{grepl} +#' @param perl logical see \link[base:grep]{grepl} +#' @param fixed logical see \link[base:grep]{grepl} +#' @param ignore.case logical see \link[base:grep]{grepl} +#' @param useBytes logical see \link[base:grep]{grepl} #' @param ... numeric indexes of desired items for items, logical vectors or criteria for boolean functions. #' @param crit vector of values/function which returns logical or vector. It will be #' converted to function of class criterion. diff --git a/R/custom_tables.R b/R/custom_tables.R index 31a57cd8..1b839e78 100644 --- a/R/custom_tables.R +++ b/R/custom_tables.R @@ -17,7 +17,7 @@ SIGNIFICANCE_OPTIONS = "significance_options" #' Functions for custom tables construction #' #' Table construction consists of at least of three functions chained with -#' \code{magrittr} pipe operator: \link[magrittr]{\%>\%}. At first we need to +#' \code{magrittr} pipe operator. At first we need to #' specify variables for which statistics will be computed with #' \code{tab_cells}. Secondary, we calculate statistics with one of #' \code{tab_stat_*} functions. And last, we finalize table creation with diff --git a/R/fctr.R b/R/fctr.R index dc834a08..8dd035eb 100644 --- a/R/fctr.R +++ b/R/fctr.R @@ -4,24 +4,24 @@ LABELS_SEP = "|" #' #' \code{fctr} converts variable to factor. It force labels usage as factor #' labels for labelled variables even if 'expss.enable_value_labels_support' set -#' to 0. For other types of variables base \link[base]{factor} is called. Factor +#' to 0. For other types of variables base \link[base:factor]{factor} is called. Factor #' levels are constructed as values labels. If label doesn't exist for #' particular value then this value remain as is - so there is no information #' lost. This levels look like as "Variable_label|Value label" if argument #' \code{prepend} set to TRUE. #' #' @param x a vector of data with labels. -#' @param ... optional arguments for \code{\link[base]{factor}} +#' @param ... optional arguments for \code{\link[base:factor]{factor}} #' @param drop_unused_labels logical. Should we drop unused value labels? #' Default is FALSE. #' @param prepend_var_lab logical. Should we prepend variable label before value #' labels? Default is TRUE. -#' @return an object of class factor. For details see base \link[base]{factor} documentation. +#' @return an object of class factor. For details see base \link[base:factor]{factor} documentation. #' #' @seealso \link{values2labels}, \link{names2labels}, \link{val_lab}, -#' \link{var_lab}. Materials for base functions: \code{\link[base]{factor}}, -#' \code{\link[base]{as.factor}}, \code{\link[base]{ordered}}, -#' \code{\link[base]{as.ordered}} +#' \link{var_lab}. Materials for base functions: \code{\link[base:factor]{factor}}, +#' \code{\link[base:factor]{as.factor}}, \code{\link[base:factor]{ordered}}, +#' \code{\link[base:factor]{as.ordered}} #' @export #' @examples #' data(mtcars) diff --git a/R/selectors.R b/R/selectors.R index ae34b49b..211d0bfd 100644 --- a/R/selectors.R +++ b/R/selectors.R @@ -32,9 +32,7 @@ #' \item{\code{\%to\%}}{ returns range of variables between \code{e1} and #' \code{e2} (similar to SPSS 'to'). \link{modify}, \link{modify_if}, #' \link{calculate}, \link{keep}, \link{except} and \link{where} support -#' \code{\%to\%}. Inside global environment \link[base]{with}, -#' \link[base]{within} \code{\%to\%} will take range from names of variables -#' sorted in the alphabetic order.} +#' \code{\%to\%}.} #' \item{\code{indirect}/\code{indirect_list}}{ are aliases for #' \code{vars}/\code{vars_list}.} #' } diff --git a/R/write_labelled.R b/R/write_labelled.R index 0fc74345..300178ce 100644 --- a/R/write_labelled.R +++ b/R/write_labelled.R @@ -68,7 +68,7 @@ #' @param fileEncoding character string: if non-empty declares the encoding to #' be used on a file (not a connection) so the character data can be #' re-encoded as they are written. Used for writing dictionary. See -#' \link[base]{file}. +#' \link[base:connections]{file}. #' #' @return Functions for writing invisibly return NULL. Functions for reading #' return labelled data.frame. @@ -838,6 +838,7 @@ old_write_labelled_csv = function(x, fileEncoding = "", remove_new_lines = TRUE, ...){ + .Deprecated("write_labelled_csv") if(remove_new_lines){ for(each in seq_along(x)){ if (is.factor(x[[each]])){ diff --git a/man/add_rows.Rd b/man/add_rows.Rd index fd2179bc..921d0c0f 100644 --- a/man/add_rows.Rd +++ b/man/add_rows.Rd @@ -28,11 +28,12 @@ columns, \code{"stop"} will raise an error.} \item{y}{data.frame/matrix/table for binding} } \value{ -See \link[base]{rbind}, \link{cro}, \link{cro_fun}, \link{fre}, \link{tables} +See \link[base:cbind]{rbind}, \link{cro}, \link{cro_fun}, \link{fre}, \link{tables} } \description{ -\code{add_rows} is similar to \link[base]{rbind} but it handles non-matching -column names. \code{\%add_rows\%} is an infix version of \code{add_rows}. +Take a sequence of vector, matrix or data-frame arguments and combine by +rows. Contrary to \link[base:cbind]{rbind} it handles non-matching column +names. \code{\%add_rows\%} is an infix version of \code{add_rows}. There is also special method for the results of \link{cro}/\link{cro_fun}/\link{tables}/\link{fre}. \code{.add_rows} is version for adding rows to default dataset. See \link{default_dataset}. diff --git a/man/compute.Rd b/man/compute.Rd index 6db4554c..9fd67b39 100644 --- a/man/compute.Rd +++ b/man/compute.Rd @@ -57,24 +57,20 @@ functions which show variable names will show labels.} } \description{ \itemize{ -\item{{\code{compute}}{ evaluates expression \code{expr} in the context of data.frame -\code{data} and return original data possibly modified. It works similar to -\code{\link[base]{within}} in base R but try to return new variables in order -of their occurrence in the expression and make available -full-featured \code{\%to\%} and \code{.N} in the expressions. See \link{vars}.}} -\item{{\code{calculate}}{ evaluates expression \code{expr} in the context of -data.frame \code{data} and return value of the evaluated expression. It works -similar to \code{\link[base]{with}} in base R but make available -full-featured \code{\%to\%} and \code{.N} in the expressions. See -\link{vars}. Function \code{use_labels} is shortcut for \code{calculate} with +\item{\code{compute}}{ evaluates expression \code{expr} in the context of data.frame +\code{data} and return original data possibly modified.} +\item{\code{calculate}}{ evaluates expression \code{expr} in the context of +data.frame \code{data} and return value of the evaluated expression. Function \code{use_labels} is shortcut for \code{calculate} with argument \code{use_labels} set to \code{TRUE}. When \code{use_labels} is TRUE -there is a special shortcut for entire data.frame - \code{..data}.}} -\item{{\code{do_if}}{ modifies only rows for which \code{cond} equals to +there is a special shortcut for entire data.frame - \code{..data}.} +\item{\code{do_if}}{ modifies only rows for which \code{cond} equals to TRUE. Other rows remain unchanged. Newly created variables also will have values only in rows for which \code{cond} have TRUE. There will be NA's in other rows. This function tries to mimic SPSS "DO IF(). ... END IF." -statement.}} +statement.} } +Full-featured \code{\%to\%} is available in the expressions for addressing +range of variables. There is a special constant \code{.N} which equals to number of cases in \code{data} for usage in expression inside \code{compute}/\code{calculate}. Inside \code{do_if} \code{.N} gives number of rows which will be affected by diff --git a/man/criteria.Rd b/man/criteria.Rd index 808fe0d7..40f32cba 100644 --- a/man/criteria.Rd +++ b/man/criteria.Rd @@ -129,13 +129,13 @@ converted to function of class criterion.} string for \code{'fixed'}) to be matched in the given character vector. Coerced by as.character to a character string if possible.} -\item{ignore.case}{logical see \link[base]{grepl}} +\item{ignore.case}{logical see \link[base:grep]{grepl}} -\item{perl}{logical see \link[base]{grepl}} +\item{perl}{logical see \link[base:grep]{grepl}} -\item{fixed}{logical see \link[base]{grepl}} +\item{fixed}{logical see \link[base:grep]{grepl}} -\item{useBytes}{logical see \link[base]{grepl}} +\item{useBytes}{logical see \link[base:grep]{grepl}} \item{...}{numeric indexes of desired items for items, logical vectors or criteria for boolean functions.} } @@ -163,15 +163,15 @@ functions which compare its argument against value.} equals to maximum or minimum.} \item{\code{'contains'}}{ searches for the pattern in the strings. By default, it works with fixed patterns rather than regular expressions. For details -about its arguments see \link[base]{grepl}} +about its arguments see \link[base:grep]{grepl}} \item{\code{'like'}}{ searches for the Excel-style pattern in the strings. You can use wildcards: '*' means any number of symbols, '?' means single symbol. Case insensitive.} \item{\code{'fixed'}}{ alias for contains.} \item{\code{'perl'}}{ such as \code{'contains'} but the pattern is perl-compatible -regular expression (\code{'perl = TRUE'}). For details see \link[base]{grepl}} +regular expression (\code{'perl = TRUE'}). For details see \link[base:grep]{grepl}} \item{\code{'regex'}}{ use POSIX 1003.2 extended regular expressions -(\code{'fixed = FALSE'}). For details see \link[base]{grepl}} +(\code{'fixed = FALSE'}). For details see \link[base:grep]{grepl}} \item{\code{'has_label'}}{ searches values which have supplied label(-s). We can used criteria as an argument for 'has_label'.} \item{\code{'to'}}{ returns function which gives TRUE for all elements of diff --git a/man/fctr.Rd b/man/fctr.Rd index 4445a175..f91428d2 100644 --- a/man/fctr.Rd +++ b/man/fctr.Rd @@ -9,7 +9,7 @@ fctr(x, ..., drop_unused_labels = FALSE, prepend_var_lab = TRUE) \arguments{ \item{x}{a vector of data with labels.} -\item{...}{optional arguments for \code{\link[base]{factor}}} +\item{...}{optional arguments for \code{\link[base:factor]{factor}}} \item{drop_unused_labels}{logical. Should we drop unused value labels? Default is FALSE.} @@ -18,12 +18,12 @@ Default is FALSE.} labels? Default is TRUE.} } \value{ -an object of class factor. For details see base \link[base]{factor} documentation. +an object of class factor. For details see base \link[base:factor]{factor} documentation. } \description{ \code{fctr} converts variable to factor. It force labels usage as factor labels for labelled variables even if 'expss.enable_value_labels_support' set -to 0. For other types of variables base \link[base]{factor} is called. Factor +to 0. For other types of variables base \link[base:factor]{factor} is called. Factor levels are constructed as values labels. If label doesn't exist for particular value then this value remain as is - so there is no information lost. This levels look like as "Variable_label|Value label" if argument @@ -41,7 +41,7 @@ summary(lm(mpg ~ fctr(unvr(am)), data = mtcars)) # without variable label } \seealso{ \link{values2labels}, \link{names2labels}, \link{val_lab}, - \link{var_lab}. Materials for base functions: \code{\link[base]{factor}}, - \code{\link[base]{as.factor}}, \code{\link[base]{ordered}}, - \code{\link[base]{as.ordered}} + \link{var_lab}. Materials for base functions: \code{\link[base:factor]{factor}}, + \code{\link[base:factor]{as.factor}}, \code{\link[base:factor]{ordered}}, + \code{\link[base:factor]{as.ordered}} } diff --git a/man/tables.Rd b/man/tables.Rd index 1faafeeb..0d518254 100644 --- a/man/tables.Rd +++ b/man/tables.Rd @@ -205,7 +205,7 @@ All of these functions return object of class } \description{ Table construction consists of at least of three functions chained with -\code{magrittr} pipe operator: \link[magrittr]{\%>\%}. At first we need to +\code{magrittr} pipe operator. At first we need to specify variables for which statistics will be computed with \code{tab_cells}. Secondary, we calculate statistics with one of \code{tab_stat_*} functions. And last, we finalize table creation with diff --git a/man/vars.Rd b/man/vars.Rd index 2ac2bf1c..eab6c6a6 100644 --- a/man/vars.Rd +++ b/man/vars.Rd @@ -80,9 +80,7 @@ variable \code{name}. It is convenient wrapper around \item{\code{\%to\%}}{ returns range of variables between \code{e1} and \code{e2} (similar to SPSS 'to'). \link{modify}, \link{modify_if}, \link{calculate}, \link{keep}, \link{except} and \link{where} support -\code{\%to\%}. Inside global environment \link[base]{with}, -\link[base]{within} \code{\%to\%} will take range from names of variables -sorted in the alphabetic order.} +\code{\%to\%}.} \item{\code{indirect}/\code{indirect_list}}{ are aliases for \code{vars}/\code{vars_list}.} } diff --git a/man/write_labelled_csv.Rd b/man/write_labelled_csv.Rd index c4a3edf5..791dd87c 100644 --- a/man/write_labelled_csv.Rd +++ b/man/write_labelled_csv.Rd @@ -139,7 +139,7 @@ will be removed when data.table issue #1109 will be fixed.} \item{fileEncoding}{character string: if non-empty declares the encoding to be used on a file (not a connection) so the character data can be re-encoded as they are written. Used for writing dictionary. See -\link[base]{file}.} +\link[base:connections]{file}.} \item{dict}{data.frame with labels - a result of \code{create_dictionary}.} }