Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ TODO.md
vignettes
^revdep$
CITATION.cff
^.claude
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Collate:
'utils-import.r'
'utils.r'
'zzz.r'
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
NeedsCompilation: no
Suggests:
rgl,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# OpenRepGrid 0.1.19 (dev version)

* `biplot2d`: Construct pole labels are automatically colorized by preference status (green = preferred,
red = non-preferred, dark gray = neutral/undefined) when preferred poles are set in the repgrid object.
New arg `c.color.preferred` controls the behavior (`NULL` = auto-detect, `TRUE` = always, `FALSE` = never) (#71).
* drop `{styler}` dependency (#72)

# OpenRepGrid 0.1.18
Expand Down
8 changes: 0 additions & 8 deletions R/bertin.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# //////////////////////////////////////////////////////////////////////////////



constructCellGrob <- function(text, gp = gpar(), horiz = TRUE) {
gp <- modifyList(gpar(fill = grey(.95)), gp)
col <- gmSelectTextColorByLuminance(gp$fill)
Expand All @@ -19,7 +18,6 @@ constructCellGrob <- function(text, gp = gpar(), horiz = TRUE) {
}



bertin1 <- function(x, draw = TRUE) {
if (!inherits(x, "repgrid")) {
stop("Object must be of class 'repgrid'")
Expand Down Expand Up @@ -88,9 +86,6 @@ bertin1 <- function(x, draw = TRUE) {
}





bertin2 <- function(x, ratings = TRUE, top = unit(40, "mm"), sides = unit(40, "mm"),
left = sides, right = sides,
cell = unit(6, "mm"), cell.height = cell, cell.width = cell,
Expand Down Expand Up @@ -176,7 +171,6 @@ bertin2 <- function(x, ratings = TRUE, top = unit(40, "mm"), sides = unit(40, "m
}



bertin2PlusLegend <- function(x, ratings = TRUE, top = unit(40, "mm"),
sides = unit(40, "mm"), left = sides, right = sides,
cell = unit(6, "mm"), cell.height = cell, cell.width = cell,
Expand Down Expand Up @@ -215,8 +209,6 @@ bertin2PlusLegend <- function(x, ratings = TRUE, top = unit(40, "mm"),
# bertin2PlusLegend(rg2, colors=c("darkred", "white"), top=unit(4, "cm"), sides=unit(4, "cm"))




# TODO: -may work with closures here to store old row and column when marking
# rows and columns?
# -splitString has a bug, breaks too late
Expand Down
3 changes: 0 additions & 3 deletions R/calc.r
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ statsDiscrepancy <- function(x, disc, sort = TRUE) {
}



# /////////////////////////////////////////////////////////////////////////////
# order elements and constructs by angles in first two dimensions from
# singular value decomposition approach (cf. Raeithel ???)
Expand Down Expand Up @@ -273,7 +272,6 @@ reorder2d <- function(x, dim = c(1, 2), center = 1, normalize = 0, g = 0, h = 1
}



#### __________________ ####
#### ELEMENTS ####

Expand Down Expand Up @@ -547,7 +545,6 @@ print.constructCor <- function(x, digits = 2, col.index = TRUE,
}



#' Root mean square (RMS) of inter-construct correlations.
#'
#' The RMS is also known as 'quadratic mean' of
Expand Down
4 changes: 0 additions & 4 deletions R/data-openrepgrid.r
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ NULL
# save("feixas2004", file="../data/feixas2004.RData")



## Leach et al. (2001) ----

#' Pre- and post therapy dataset from Leach et al. (2001).
Expand Down Expand Up @@ -335,7 +334,6 @@ NULL
# save("leach2001a", file="../data/leach2001a.RData")



# name.abb <- c("CS", "SN", "WG", "MG", "Fa", "Pa", "IS", "Mo", "AC") # not included yet
# args <- list(
# name= c("Child self", "Self now", "Women in general",
Expand Down Expand Up @@ -369,7 +367,6 @@ NULL
# save("leach2001b", file="../data/leach2001b.RData")



## Mackay (1992) ----

#' Grid data from Mackay (1992).
Expand Down Expand Up @@ -458,7 +455,6 @@ NULL
# save("raeithel", file="../data/raeithel.RData")



## Slater (1977a) ----

#' Drug addict's grid data set from Slater (1977, p. 32).
Expand Down
1 change: 0 additions & 1 deletion R/distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ quasiDistributionDistanceSlater <- function(reps, nc, ne, range,
# }



# Return a list with the mean and sd as indicated in Hartmann's (1992) paper.
#
getSlaterPaperPars <- function(nc) {
Expand Down
2 changes: 0 additions & 2 deletions R/export.r
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ saveAsWorksheet <- function(x, wb, format = "wide", sheet = NULL, default_sheet
}



# saveAsExcelv2 <- function(x, file, format = "wide", sheet = "grid") {
# ext <- tools::file_ext(file)
# if (ext != "xlsx") {
Expand Down Expand Up @@ -383,7 +382,6 @@ add_one_sheet_with_grid <- function(x, wb, format = "wide", sheet = "grid") {
}



#' Export a grid to dataframe with wide format
#' @param x A `repgrid` object.
#' @export
Expand Down
20 changes: 6 additions & 14 deletions R/gmMain.r
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ gmSelectTextColorByLuminance <- function(hex, breaks = c(-1, 50, 101), breakColo
# //////////////////////////////////////////////////////////////////////////////



# //////////////////////////////////////////////////////////////////////////////

# like a gmTextBox
Expand Down Expand Up @@ -324,7 +323,6 @@ gmSplitTextBox <- function(text, x = unit(0.5, "npc"), y = unit(0.5, "npc"), jus
}



### NOT RUN
# text <- "some random longer text that might be the label of an item"
# grid.draw(gmSplitTextGrob(text, horiz=T, just=c("center", "center")))
Expand Down Expand Up @@ -352,7 +350,6 @@ gmSplitTextBox <- function(text, x = unit(0.5, "npc"), y = unit(0.5, "npc"), jus
# popViewport()



## matrix of text with random orientation and random fore- and background color
# grid.newpage()
# text <- "some random longer text that might be the label of an item"
Expand Down Expand Up @@ -428,22 +425,19 @@ gmMakeVpBorders <- function(side, col, lwd, ...) {
# popViewport()



# //////////////////////////////////////////////////////////////////////////////

# gmBulletPointsBox
# A function that prints a list of text elements as bullet points
# Bullets can be chosen any pch, numbers, letters or any other vector.



# //////////////////////////////////////////////////////////////////////////////

# gmProfileLines
# ask Hadley first if he already implicitly has it...



# //////////////////////////////////////////////////////////////////////////////

# gmRandomColor
Expand Down Expand Up @@ -479,7 +473,6 @@ gmRandomColor <- function(n = 1, h = runif(n) * 360, s = runif(n), v = runif(n),
# gmRandomColor(30, h=100:200, v=3:10/10, p=T)



# //////////////////////////////////////////////////////////////////////////////

# gmArrowIndicator
Expand Down Expand Up @@ -518,7 +511,6 @@ gmRandomColor <- function(n = 1, h = runif(n) * 360, s = runif(n), v = runif(n),
# }



gmArrowIndicatorGrob <- function(angle = 0, col = "black", size = 5, circle = FALSE, initangle = 0, ...) {
# gp <- modifyList(gpar(fill="black", col=NA, lwd=1, lineend ="square", # set default gpar and overwrite if provided
# linejoin ="mitre", linemitre=1), gp)
Expand Down Expand Up @@ -715,11 +707,12 @@ gmSelectColorByValue <- function(x, breaks = seq(0, 100, by = 10),
# TODO: automatic deterination of wFirstRow by max stringwidth

gmLegend <- function(
x, y, pch, symbol = FALSE, col, labels, hgap = unit(
0.5,
"lines"
), wFirstCol = unit(2, "lines"), vgap = unit(0.3, "lines"), default_units = "lines",
gpRect = gpar(), gpText = gpar(), draw = TRUE, title = "Legend:") {
x, y, pch, symbol = FALSE, col, labels, hgap = unit(
0.5,
"lines"
), wFirstCol = unit(2, "lines"), vgap = unit(0.3, "lines"), default_units = "lines",
gpRect = gpar(), gpText = gpar(), draw = TRUE, title = "Legend:"
) {
labels <- as.character(labels)
if (is.logical(title) && !title) {
title <- NULL
Expand Down Expand Up @@ -807,7 +800,6 @@ gmLegend <- function(
# gpRect=gpar(col=1, fill=grey(.95), lty=3), gpText=gpar(col=grey(.5), cex=.7), title = NULL)



# //////////////////////////////////////////////////////////////////////////////

# gmLegends_2
Expand Down
2 changes: 0 additions & 2 deletions R/import.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#



#' convertImportObjectToRepGridObject.
#'
#' Convert the returned object from an import function into a `repgrid`
Expand Down Expand Up @@ -428,7 +427,6 @@ importGridstat <- function(file, dir = NULL, min = NULL, max = NULL) {
}



## GRIDCOR ------------------------------------------------------------------------------------

# gridcor outpout has the following form:
Expand Down
36 changes: 16 additions & 20 deletions R/measures.r
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ indexPvaff <- function(x, method = 1) {
# }



#' Bieri's index of cognitive complexity
#'
#' The index builds on the number of rating matches between pairs of constructs. It is the relation between the total
Expand Down Expand Up @@ -2304,7 +2303,6 @@ print.indexDilemma <- function(x, digits = 2, output = "SPCD", ...) {
}



#' Implicative Dilemmas
#'
#' Implicative dilemmas are closely related to the notion of conflict. An implicative dilemma arises when a desired
Expand Down Expand Up @@ -2487,7 +2485,6 @@ indexDilemma <- function(x, self = 1, ideal = ncol(x),
}



#' Plot method for indexDilemma (network graph)
#'
#' Produces a network graph using of the detected implicative dilemmas using the
Expand All @@ -2510,21 +2507,22 @@ indexDilemma <- function(x, self = 1, ideal = ncol(x),
#' @export
#'
plot.indexDilemma <- function(
x,
layout = "rows",
both.poles = TRUE,
node.size = 50,
node.text.cex = 1,
node.label.color = "black",
node.color.discrepant = "darkolivegreen3",
node.color.congruent = "lightcoral",
edge.label.color = grey(.4),
edge.label.cex = 1,
edge.digits = 2,
edge.arrow.size = .5,
edge.color = grey(.6),
edge.lty = 2,
...) {
x,
layout = "rows",
both.poles = TRUE,
node.size = 50,
node.text.cex = 1,
node.label.color = "black",
node.color.discrepant = "darkolivegreen3",
node.color.congruent = "lightcoral",
edge.label.color = grey(.4),
edge.label.cex = 1,
edge.digits = 2,
edge.arrow.size = .5,
edge.color = grey(.6),
edge.lty = 2,
...
) {
id <- x # renamed from 'id' to 'x' to match arg in print generic

# response in case no dilemmas were found
Expand Down Expand Up @@ -2651,8 +2649,6 @@ plot.indexDilemma <- function(
# }




# //////////////////////////////////////////////////////////////////////////////

# Pemutation test to test if grid is random.
Expand Down
26 changes: 26 additions & 0 deletions R/preferred_poles.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,29 @@ preferredPolesByIdeal <- function(x, ideal, none_range = NULL, align = FALSE) {
}
x
}


# Map preferred pole status to colors for each construct.
# Returns list(left = <color vector>, right = <color vector>).
# @keywords internal
preferred_pole_colors <- function(x,
col_preferred = "green",
col_nonpreferred = "red",
col_neutral = grey(.4)) {
preferred <- preferredPoles(x)
colors_left <- case_when(
preferred == "left" ~ col_preferred,
preferred == "both" ~ col_preferred,
preferred == "none" ~ col_neutral,
preferred == "right" ~ col_nonpreferred,
is.na(preferred) ~ col_neutral
)
colors_right <- case_when(
preferred == "right" ~ col_preferred,
preferred == "both" ~ col_preferred,
preferred == "none" ~ col_neutral,
preferred == "left" ~ col_nonpreferred,
is.na(preferred) ~ col_neutral
)
list(left = colors_left, right = colors_right)
}
Loading
Loading