Skip to content

Commit 9187ec8

Browse files
committed
add missing imports & cosmetic tweaks
* import packages used only in ui.R and server.R * change import directives so that no functions are masked thus avoiding import warnings * Code now compliant with tidyverse style guide using the `styler` package
1 parent ff8c255 commit 9187ec8

File tree

18 files changed

+722
-693
lines changed

18 files changed

+722
-693
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ dev$
1515
^\.dockerignore$
1616
^LICENSE\.md$
1717
^\.github$
18+
^inst/extdata/software-animation\.gif$

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Description: Shiny UI to identify cliques of related constructs in repertory gri
2222
See Burr, King, & Heckmann (2020) <doi:10.1080/14780887.2020.1794088> for a description
2323
of the interpretive clustering (IC) method.
2424
Version: 0.6.1
25-
Date: 2022-08-27
25+
Date: 2022-10-25
2626
Imports:
2727
graphics,
2828
grDevices,
@@ -41,7 +41,6 @@ Imports:
4141
openxlsx,
4242
DT,
4343
magrittr,
44-
tidyverse,
4544
dplyr,
4645
stringr,
4746
reshape2,
@@ -50,7 +49,8 @@ Imports:
5049
igraph,
5150
tidyr,
5251
withr,
53-
RColorBrewer
52+
RColorBrewer,
53+
tidyverse
5454
Suggests:
5555
knitr,
5656
rmarkdown,

NAMESPACE

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ export(ic)
1212
export(make_names)
1313
export(make_names_vec)
1414
export(network_graph_images)
15+
import(formattable)
1516
import(grDevices)
1617
import(graphics, except = box)
17-
import(igraph, except = compare)
18+
import(igraph, except = c(compare, normalize))
1819
import(openxlsx)
1920
import(reshape2)
21+
import(rintrojs)
22+
import(shinyFeedback)
23+
import(shinyWidgets, except = c(progressBar, alert))
24+
import(shinydashboard, except = c(dashboardPage, dashboardSidebar, box, dashboardHeader, taskItem, notificationItem, messageItem))
25+
import(shinydashboardPlus)
26+
import(shinyjs)
27+
import(shinythemes)
28+
import(splines)
2029
import(stringr)
30+
import(tidyverse)
2131
import(utils)
2232
importFrom(dplyr,case_when)
2333
importFrom(dplyr,filter)
@@ -26,5 +36,6 @@ importFrom(dplyr,recode)
2636
importFrom(dplyr,select)
2737
importFrom(magrittr,"%>%")
2838
importFrom(shinyBS,tipify)
39+
importFrom(shinycssloaders,withSpinner)
2940
importFrom(stats,na.omit)
3041
importFrom(withr,with_par)

NEWS.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ output: html_document
55

66
## v0.6.1
77

8+
- Code now compliant with tidyverse style guide using the `styler` package
89
- Add animated gif image with short software overview to README
910
- New `Sample output`tab added with extracts from the output for Sylvia's grid
1011
- Additional test raising test coverage to over 90%

R/01-utils.R

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
#////////////////////////////////////////////////////////////
1+
# ////////////////////////////////////////////////////////////
22
#
33
# Helper functions
44
#
5-
#////////////////////////////////////////////////////////////
5+
# ////////////////////////////////////////////////////////////
66

77

88
#' Create empty dataframe while keeping columns names
9-
#'
9+
#'
1010
#' Also works on lists if dataframes are contained as list elements.
1111
#' @param x Dataframe or list.
1212
#' @export
1313
#' @keywords internal
14-
#'
15-
emptify_object <- function(x)
16-
{
14+
#'
15+
emptify_object <- function(x) {
1716
if (is.data.frame(x)) {
1817
return(x[integer(0), ])
1918
}
20-
19+
2120
for (nm in names(x)) {
2221
df <- x[[nm]]
2322
if (is.data.frame(df)) {
24-
df <- df[integer(0), ]
23+
df <- df[integer(0), ]
2524
} else {
26-
df <- list()
25+
df <- list()
2726
}
2827
x[[nm]] <- df
2928
}
@@ -32,65 +31,62 @@ emptify_object <- function(x)
3231

3332

3433
#' Default datatable output when loading
35-
#'
34+
#'
3635
#' @param text Text to be shown
3736
#' @param header Table header, defaults to an empty string.
3837
#' @export
3938
#' @keywords internal
40-
dt_default <- function(text = "Waiting for data ...",
41-
header = "")
42-
{
39+
dt_default <- function(text = "Waiting for data ...",
40+
header = "") {
4341
df <- data.frame(col1 = text)
4442
names(df) <- header
45-
43+
4644
# create datatable and format
4745
df %>%
48-
(DT::datatable)(filter = "none",
49-
selection = "none",
50-
colnames = header,
51-
class = 'compact', rownames = FALSE,
52-
options = list(
53-
dom = 't',
54-
ordering = TRUE,
55-
pageLength = 10
56-
)
57-
)
46+
(DT::datatable)(filter = "none",
47+
selection = "none",
48+
colnames = header,
49+
class = "compact", rownames = FALSE,
50+
options = list(
51+
dom = "t",
52+
ordering = TRUE,
53+
pageLength = 10
54+
)
55+
)
5856
}
5957

6058

6159
#' String splitter for comma separated values in Excel cell
62-
#'
60+
#'
6361
#' @param x String to be split
6462
#' @export
6563
#' @keywords internal
6664
#' @examples
67-
#'
68-
#' cell_text_split("10, 20,30" )
69-
#' cell_text_split("; , 10 ,,, 20;30,," ) # very robust
70-
#'
71-
cell_text_split <- function(x)
72-
{
73-
x %>%
74-
stringr::str_replace_all(" +|;+", ",") %>% # space, semicolon to comma
75-
stringr::str_replace_all(",+", ",") %>% # several commas to one
76-
stringr::str_replace_all("^,+|,+$", "") %>% # remove leading and trainling commas
77-
strsplit(",") # split string at comma
65+
#'
66+
#' cell_text_split("10, 20,30")
67+
#' cell_text_split("; , 10 ,,, 20;30,,") # very robust
68+
#'
69+
cell_text_split <- function(x) {
70+
x %>%
71+
stringr::str_replace_all(" +|;+", ",") %>% # space, semicolon to comma
72+
stringr::str_replace_all(",+", ",") %>% # several commas to one
73+
stringr::str_replace_all("^,+|,+$", "") %>% # remove leading and trainling commas
74+
strsplit(",") # split string at comma
7875
}
7976

8077

8178
#' @rdname make-names
8279
#' @export
83-
make_names_vec <- function(x)
84-
{
80+
make_names_vec <- function(x) {
8581
nms <- tolower(x)
86-
nms <- stringr::str_replace_all(nms, "[[:blank:]]+", "_") # replace blanks
87-
nms <- stringr::str_replace_all(nms, "\\.|-|/|\\(|\\)|&|\\?", "_") # replace . - \ ? to _ (underscore)
88-
nms <- stringr::str_replace_all(nms, "[_]+", "_") # replace multiple underscores by one
89-
nms <- stringr::str_replace_all(nms, "[_]+$", "") # remove trailing underscores
90-
nms <- stringr::str_replace_all(nms, "\u00DF", "ss")
91-
nms <- stringr::str_replace_all(nms, "\u00E4", "ae") # replace German umlauts by their two letter ASCII version
92-
nms <- stringr::str_replace_all(nms, "\u00FC", "ue")
93-
nms <- stringr::str_replace_all(nms, "\u00F6", "oe")
82+
nms <- stringr::str_replace_all(nms, "[[:blank:]]+", "_") # replace blanks
83+
nms <- stringr::str_replace_all(nms, "\\.|-|/|\\(|\\)|&|\\?", "_") # replace . - \ ? to _ (underscore)
84+
nms <- stringr::str_replace_all(nms, "[_]+", "_") # replace multiple underscores by one
85+
nms <- stringr::str_replace_all(nms, "[_]+$", "") # remove trailing underscores
86+
nms <- stringr::str_replace_all(nms, "\u00DF", "ss")
87+
nms <- stringr::str_replace_all(nms, "\u00E4", "ae") # replace German umlauts by their two letter ASCII version
88+
nms <- stringr::str_replace_all(nms, "\u00FC", "ue")
89+
nms <- stringr::str_replace_all(nms, "\u00F6", "oe")
9490
nms
9591
}
9692

@@ -101,23 +97,22 @@ make_names_vec <- function(x)
10197
#' @keywords internal
10298
#' @rdname make-names
10399
#' @export
104-
make_names <- function(x)
105-
{
106-
if (!is.data.frame(x))
100+
make_names <- function(x) {
101+
if (!is.data.frame(x)) {
107102
stop("x muste be a dataframe")
108-
109-
names(x) <- make_names_vec( names(x) )
103+
}
104+
105+
names(x) <- make_names_vec(names(x))
110106
x
111107
}
112108

113109

114110
#' Format as x digit number
115-
#'
111+
#'
116112
#' @export
117113
#' @keywords internal
118-
#'
119-
fnum <- function(x, digits = 2)
120-
{
114+
#'
115+
fnum <- function(x, digits = 2) {
121116
x <- round(x, digits)
122117
formatC(x, digits = digits, format = "f")
123118
}

0 commit comments

Comments
 (0)