Skip to content

Commit

Permalink
fix addiotional CRAN comments
Browse files Browse the repository at this point in the history
fix docs

fix more check comments

some more fixes

fix docs

more fixes

more fixes

add comma
  • Loading branch information
markheckmann committed Feb 18, 2024
1 parent f4e14af commit 5c63b63
Show file tree
Hide file tree
Showing 35 changed files with 164 additions and 315 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ cran-comments.md
^doc$
^Meta$
^vignettes/web$
TODO.md
TODO.md
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Description: Analyze repertory grids, a qualitative-quantitative
Version: 0.1.15
Date: 2024-02-18
Encoding: UTF-8
URL: https://github.com/markheckmann/OpenRepGrid, http://markheckmann.github.io/OpenRepGrid/
URL: https://github.com/markheckmann/OpenRepGrid
Imports:
methods,
graphics,
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ export(alignByLoadings)
export(apply_pb)
export(as.gridlist)
export(bertin)
export(bertinBase)
export(bertinCluster)
export(bind)
export(bindConstructs)
export(biplot2d)
export(biplot3d)
export(biplot3dBase2)
export(biplotDraw)
export(biplotEsa2d)
export(biplotEsa3d)
Expand Down
46 changes: 23 additions & 23 deletions R/bertin.r
Original file line number Diff line number Diff line change
Expand Up @@ -222,29 +222,29 @@ bertin2PlusLegend <- function(x, ratings = TRUE, top = unit(40, "mm"),
# -splitString has a bug, breaks too late
# -trimming of elements and constructs
#
#' Workhorse for the biplot printing.
#'
#' Prints a bertin to the output
#' device. It uses the R base graphics system and
#' this is very fast. This is useful for working with grids. Not so much for
#' producing high-quality output.
#'
#' @param x `repgrid` object.
#' @param ratings Vector. rating scores are printed in the cells
#' @param margins Vector of length three (default `margins=c(0,1,1)`).
#' 1st element denotes the left, 2nd the upper and 3rd the
#' right margin in npc coordinates (i.e. 0 to zero).
#' @param trim Vector (default `trim=c(F,F)`).If a number the string
#' is trimmed to the given number of characters. If set
#' to TRUE the labels are trimmed to the available space
#' @param add Logical. Whether to add bertin to existent plot (default is
#' `FALSE`). If `TRUE, plot.new()` will not be called
#' `par(new=TRUE)`.
#' @return `NULL` just for printing.
#'
#' @export
#' @keywords internal
#'
# Workhorse for the biplot printing.
#
# Prints a bertin to the output
# device. It uses the R base graphics system and
# this is very fast. This is useful for working with grids. Not so much for
# producing high-quality output.
#
# @param x `repgrid` object.
# @param ratings Vector. rating scores are printed in the cells
# @param margins Vector of length three (default `margins=c(0,1,1)`).
# 1st element denotes the left, 2nd the upper and 3rd the
# right margin in npc coordinates (i.e. 0 to zero).
# @param trim Vector (default `trim=c(F,F)`).If a number the string
# is trimmed to the given number of characters. If set
# to TRUE the labels are trimmed to the available space
# @param add Logical. Whether to add bertin to existent plot (default is
# `FALSE`). If `TRUE, plot.new()` will not be called
# `par(new=TRUE)`.
# @return `NULL` just for printing.
#
# @export
# @keywords internal
#
bertinBase <- function(nrow, ncol, labels = "", labels.elements = "",
labels.left = "", labels.right = "",
col.text = NA, cex.text = .6, cex.elements = .7,
Expand Down
6 changes: 3 additions & 3 deletions R/calc.r
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ calcAngles <- function(x, dim = c(1, 2), clockwise = TRUE) {
#'
#' Reorder indexes for constructs and elements are calculated using the coordinates of the given dimensions.
#'
#' @param x`repgrid` object that has been submitted to [calcBiplotCoords()].
#' @param x A `repgrid` object that has been submitted to [calcBiplotCoords()].
#' @param dim Dimensions used to calculate angles for reordering grid.
#' @param clockwise Logical. Positive angles are clockwise with x axis as basis.
#' @return A list containing the indexes to reorder the grid. The first list element for the constructs, the second
Expand Down Expand Up @@ -631,14 +631,14 @@ print.rmsCor <- function(x, digits = 2, ...) {
#' variable is set as dependent and independent.
#' The direction of dependency needs to be specified.
#'
#' @param x `repgrid` object
#' @param x `repgrid` object.
#' @param dependent A string denoting the direction of dependency in the output
#' table (as d is asymmetrical). Possible values are `"columns"`
#' (the default) for setting the columns as dependent, `"rows"`
#' for setting the rows as the dependent variable and
#' `"symmetric"` for the
#' symmetrical Somers' d measure (the mean of the two directional
#' values for code{"columns"} and `"rows"`).
#' values for `"columns"` and `"rows"`).
#' @param trim The number of characters a construct is trimmed to (default is
#' `30`). If `NA` no trimming occurs. Trimming
#' simply saves space when displaying correlation of constructs
Expand Down
28 changes: 10 additions & 18 deletions R/dev-functions.r
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ randomGrids <- function(rep = 3, nc = 10, ne = 15, nwc = 8, nwe = 5,
#' All Slater distances are returned as a vector. The values can be used e.g. to assess the
#' distributions standard deviation.
#'
#' @param rep Number of grids to be produced (default is `3`).
#' @param reps Number of grids to be produced (default is `3`).
#' @param nc Number of constructs (default 10).
#' @param ne Number of elements (default 15).
#' @param range Minimal and maximal scale value (default `c(1, 5)`).
Expand All @@ -129,7 +129,7 @@ randomGrids <- function(rep = 3, nc = 10, ne = 15, nwc = 8, nwe = 5,
#' hist(vals, breaks = 50)
#' }
#'
quasiDistributionDistanceSlater <- function(rep, nc, ne, range, prob = NULL, progress = TRUE) {
quasiDistributionDistanceSlater <- function(reps, nc, ne, range, prob = NULL, progress = TRUE) {
quasis <- randomGrids(rep, nc = nc, ne = ne, range = range, prob = prob, options = 0)
if (progress) { # whether to show progress bar
lapply_fun <- lapply_pb
Expand Down Expand Up @@ -176,19 +176,18 @@ permuteConstructs <- function(x, progress = TRUE) {
}


#' Permute rows, columns or whole grid matrix.
#'
#' Generate one or many permutations of the grid by shuffling
#' the rows, the columns or the whole grid matrix.
#'
#' @title Permute rows, columns or whole grid matrix.
#' @param x `repgrid` object.
#' @param along What to permute. `along=1` (default) will permute the rows
#' `along=2` the columns, `along=3` the whole matrix.
#' @param n The number of permutations to produce.
#' @return A `repgrid` object if `n=1` or a list of
#' `repgrid` objects if `n>1`.
#' @param x A `repgrid` object.
#' @param along What to permute. `along=1` (default) will permute the rows
#' `along=2` the columns, `along=3` the whole matrix.
#' @param n The number of permutations to produce.
#' @returns A `repgrid` object if `n = 1` or a list of `repgrid` objects if `n > 1`.
#' @export
#' @keywords internal
#'
#' @keywords internal
#' @examples \dontrun{
#'
#' # permute grid
Expand Down Expand Up @@ -227,10 +226,3 @@ permuteGrid <- function(x, along = 1, n = 1) {
}
res
}



### TODO ###
# Permutation test

# Slater writes:
10 changes: 4 additions & 6 deletions R/import.r
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#' Convert the returned object from an import function into a `repgrid`
#' object. Works for all importXInternal functions (except scivesco).
#'
#' @param x object returned from an import function.
#' @return `repgrid` object.
#' @param import List with relevant entries.
#' @keywords internal
#' @export
#'
Expand Down Expand Up @@ -499,7 +498,7 @@ importGridstat <- function(file, dir = NULL, min = NULL, max = NULL) {
#' (default `NULL`).
#' @note Note that the GRIDCOR data sets the minimum ratings scale range to 1.
#' The maximum value can differ and is defined in the data file.
#' @references <https://www.ub.edu/terdep/gridcor.html>
#' @references <https://repertorygrid.net/en/>
#'
#' @export
#' @keywords internal
Expand Down Expand Up @@ -598,7 +597,7 @@ importGridcorInternal <- function(file, dir = NULL) {
#' @export
#' @references Feixas, G., & Cornejo, J. M. (2002). GRIDCOR: Correspondence Analysis
#' for Grid Data (version 4.0). Barcelona: Centro de Terapia Cognitiva.
#' Retrieved from <https://www.ub.edu/terdep/pag/index.html>.
#' Retrieved from <https://repertorygrid.net/en/>.
#'
#' @seealso [importGridcor()],
#' [importGridstat()],
Expand Down Expand Up @@ -1016,8 +1015,7 @@ importScivescoInternal <- function(file, dir = NULL) {
#' Convert the returned object from the sci:vesco import function into a `repgrid`
#' object.
#'
#' @param x object returned from an import function.
#' @return `repgrid` object.
#' @param import List with relevant entries.
#' @keywords internal
#' @export
convertScivescoImportObjectToRepGridObject <- function(import) {
Expand Down
50 changes: 25 additions & 25 deletions R/measures.r
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ print_square_matrix <- function(x, names = NA, trim = NA,
#' * `total_elements` Total number of matches across elements.
#' * `constructs`: Matrix with no. of matches for constructs.
#' * `elements`: Matrix with no. of matches for elements.
#'
#'
#' @keywords internal
#' @export
#' @example inst/examples/example-matches.R
Expand Down Expand Up @@ -359,7 +359,7 @@ indexPvaff <- function(x, method = 1) {
#
# @param x Object of class indexPvaff.
# @param digits Numeric. Number of digits to round to (default is
# \code{2}).
# `2`).
# @param ... Not evaluated.
# @export
# @method print indexPvaff
Expand Down Expand Up @@ -619,7 +619,7 @@ print.indexDilemmatic <- function(x, output = "SD", ...) {
#' Implementation as in the Gridcor program and explained on the correspoding help pages: "\ldots the sum of the
#' squared values of the correlations of each construct with the rest of the constructs, averaged by the total number
#' of constructs minus one. This process is repeated with each element, and the overall Intensity is calculated by
#' averaging the intensity scores of constructs and elements." <https://www.ub.edu/terdep/pag/man11.html>. Currently
#' averaging the intensity scores of constructs and elements." (Gridcor manual). Currently
#' the total is calculated as the unweighted average of all single scores (for elements and construct).
#'
#' @title Intensity index
Expand Down Expand Up @@ -1183,23 +1183,23 @@ indexConflict1 <- function(x) {
#'
#' Description of the balance / imbalance assessment:
#'
#' 1. Order correlations of the triad by absolute magnitude, so that \eqn{ r_{max} > r_{mdn} > r_{min} }{r_max > r_mdn > r_min}.
#' 2. Apply Fisher's Z-transformation and division by 3 to yield values between 1 and -1 (\eqn{ Z_{max} > Z_{mdn} > Z_{min} }{Z_max > Z_mdn > Z_min}).
#' 1. Order correlations of the triad by absolute magnitude, so that \eqn{ r_{max} > r_{mdn} > r_{min}}, \eqn{r_{max} > r_{mdn} > r_{min}}.
#' 2. Apply Fisher's Z-transformation and division by 3 to yield values between 1 and -1 (\eqn{ Z_{max} > Z_{mdn} > Z_{min}, Z_{max} > Z_{mdn} > Z_{min}}).
#' 3. Check whether the triad is balanced by assessing if the following relation holds:
#'
#' - If \eqn{ Z_{max} Z_{mdn} > 0 }{ Z_max x Z_mdn > 0},
#' the triad is balanced if \eqn{ Z_{max} Z_{mdn} - Z_{min} <= crit }
#' { Z_max x Z_mdn - Z_min <= crit }.
#' - If \eqn{ Z_{max} Z_{mdn} < 0 }{ Z_max x Z_mdn < 0},
#' the triad is balanced if \eqn{ Z_{min} - Z_{max} Z_{mdn} <= crit }
#' { Z_min - Z_max x Z_mdn <= crit }.
#' - If \eqn{Z_{max} Z_{mdn} > 0, Z_{max} x Z_{mdn} > 0},
#' the triad is balanced if \eqn{Z_{max} Z_{mdn} - Z_{min} <= crit},
#' \eqn{Z_{max} x Z_{mdn} - Z_{min} <= crit}.
#' - If \eqn{Z_{max} Z_{mdn} < 0, Z_{max} x Z_{mdn} < 0},
#' the triad is balanced if \eqn{Z_{min} - Z_{max} Z_{mdn} <= crit},
#' \eqn{Z_{min} - Z_{max} x Z_{mdn} <= crit}.
#'
#' @section Personal remarks (MH): I am a bit suspicious about step 2 from above. To devide by 3 appears pretty arbitrary.
#' The r for a z-values of 3 is 0.9950548 and not 1.
#' The r for 4 is 0.9993293. Hence, why not a value of 4, 5, or 6?
#' Denoting the value to devide by with `a`, the relation for the
#' first case translates into \eqn{ a Z_{max} Z_{mdn} <= \frac{crit}{a} + Z_{min} }
#' { a x Z_max x Z_mdn =< crit/a + Z_min}. This shows that a bigger value of `a`
#' first case translates into \eqn{a Z_{max} Z_{mdn} <= \frac{crit}{a} + Z_{min}},
#' \eqn{a x Z_{max} x Z_{mdn} =< crit/a + Z_{min}}. This shows that a bigger value of `a`
#' will make it more improbable that the relation will hold.
#'
#' @param x A `repgrid` object.
Expand Down Expand Up @@ -1752,37 +1752,37 @@ indexDilemmaShowCorrelationDistribution <- function(x, e1, e2) {

# internal workhorse for indexDilemma
#
# @param x \code{repgrid} object.
# @param x `repgrid` object.
# @param self Numeric. Index of self element.
# @param ideal Numeric. Index of ideal self element.
# @param diff.mode Numeric. Method adopted to classify construct pairs into congruent
# and discrepant. With \code{diff.mode=1}, the minimal and maximal
# score difference criterion is applied. With \code{diff.mode=0} the Mid-point
# rating criterion is applied. Default is \code{diff.mode=1}.
# and discrepant. With `diff.mode=1`, the minimal and maximal
# score difference criterion is applied. With `diff.mode=0` the Mid-point
# rating criterion is applied. Default is `diff.mode=1`.

# @param diff.congruent Is used if \code{diff.mode=1}. Maximal difference between
# @param diff.congruent Is used if `diff.mode=1`. Maximal difference between
# element ratings to define construct as congruent (default
# \code{diff.congruent=1}). Note that the value
# `diff.congruent=1`). Note that the value
# needs to be adjusted by the user according to the rating scale
# used.
# @param diff.discrepant Is used if \code{diff.mode=1}. Minimal difference between
# @param diff.discrepant Is used if `diff.mode=1`. Minimal difference between
# element ratings to define construct as discrepant (default
# \code{diff.discrepant=4}). Note that the value
# `diff.discrepant=4`). Note that the value
# needs to be adjusted by the user according to the rating scale
# used.
# @param diff.poles Not yet implemented.
# @param r.min Minimal correlation to determine implications between
# constructs ([0, 1]).
# @param exclude Whether to exclude the elements self and ideal self
# during the calculation of the inter-construct correlations.
# (default is \code{FALSE}).
# (default is `FALSE`).
# @param index Whether to print index numbers in front of each construct
# (default is \code{TRUE}).
# (default is `TRUE`).
# @param trim The number of characters a construct (element) is trimmed to (default is
# \code{20}). If \code{NA} no trimming is done. Trimming
# `20`). If `NA` no trimming is done. Trimming
# simply saves space when displaying the output.
# @param digits Numeric. Number of digits to round to (default is
# \code{2}).
# `2`).
# @export
# @keywords internal
# @return A list with four elements containing different steps of the
Expand Down
2 changes: 1 addition & 1 deletion R/openrepgrid.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' - Contributors: Richard C. Bell, Alejandro García Gutiérrez (@j4n7), Diego Vitali (@artoo-git), José Antonio
#' González Del Puerto (@MindCartographer), Jonathan D. Raskin
#'
#' - How to contribute: You can [contribute in various ways](http://docu.openrepgrid.org/contribute.html).
#' - How to contribute: You can [contribute in various ways](https://docs.openrepgrid.org/CONTRIBUTING.html).
#' The `OpenRepGrid` code is hosted on [GitHub](https://github.com/markheckmann/OpenRepGrid), where you can issue bug
#' reports or feature requests. You may email your request to the package maintainer.
#'
Expand Down
3 changes: 2 additions & 1 deletion R/perturbate.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#' Randomly subtract or add an amount to a proportion of the grid ratings. This
#' emulates randomness during the rating process, producing a grid which might
#' also have resulted.
#'
#' @param x A `repgrid` object.
#' @param n Number of perturbated grid to generate.
#' @param prop The proportion of ratings to be perturbated.
#' @param amount The amount set of possible perturbations. Will depend on scale
#' range. Usually {-1, 1} are reasonable settings
#' range. Usually `{-1, 1}` are reasonable settings.
#' @param prob Probability for each amount to occur.
#' @export
#' @example inst/examples/example-perturbate.R
Expand Down
2 changes: 1 addition & 1 deletion R/repgrid-output.r
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ df_out <- function(df, # data frame

# Show method for repgrid
#
# @param object a \code{repgrid} object
# @param object a `repgrid` object
# @docType methods
# @usage \S4method{show}{repgrid}(object)
# @include repgrid.r
Expand Down
14 changes: 7 additions & 7 deletions R/repgrid-plots.r
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mapCoordinatesToValue <- function(z, val.range = c(.5, 1)) {
#' the mapped values are transformed into hex color values.
#'
#' @param z numeric vector.
#' @param color vector of length two giving color values `c("white", "black")`.
#' @param colors vector of length two giving color values `c("white", "black")`.
#' @param val.range numeric vector of lengths two (default `c(.2, .8)`).
#' @return numeric vector
#' @keywords internal
Expand Down Expand Up @@ -179,17 +179,17 @@ calcCoordsBorders <- function(x, y, xmax = 1, ymax = 1, cx = 0, cy = 0) {
#
# TODO: supply x.ext in mm and convert to usr coords
#
# @param xy \code{dataframe} with x and y coords.
# @param xy `dataframe` with x and y coords.
# @param labels vector of strings.
# @param cex vector of cex values (default is \code{.7}).
# @param cex vector of cex values (default is `.7`).
# @param x.ext scalar giving the horizontal margin
# of the rectangle in NDC coordinates
# (default is \code{.02}).
# (default is `.02`).
# @param y.ext scalar giving the vertical margin
# of the rectangle in NDC coordinates
# (default is \code{.02}).
# @return \code{dataframe} with coordinates for the lower left and
# upper right rectangle borders (\code{x0, y0, x1, y1}).
# (default is `.02`).
# @return `dataframe` with coordinates for the lower left and
# upper right rectangle borders (`x0, y0, x1, y1`).
#
calcRectanglesCoordsForLabels <- function(xy, labels, cex = .7,
x.ext = .02, y.ext = .02) {
Expand Down
Loading

0 comments on commit 5c63b63

Please sign in to comment.