Skip to content

Commit 3f14ea3

Browse files
authored
Merge pull request #4 from ck37/fix-check-issues
Fix most of the remaining devtools::check() issues - achieve 0 errors, 0 warnings
2 parents 9c28eef + 5142508 commit 3f14ea3

File tree

11 files changed

+821
-687
lines changed

11 files changed

+821
-687
lines changed

.github/workflows/r-check.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: R Package Check
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
R-CMD-check:
12+
runs-on: ${{ matrix.config.os }}
13+
14+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
config:
20+
- {os: ubuntu-latest, r: 'release'}
21+
- {os: ubuntu-latest, r: 'devel'}
22+
- {os: windows-latest, r: 'release'}
23+
- {os: macOS-latest, r: 'release'}
24+
25+
env:
26+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
27+
R_KEEP_PKG_SOURCE: yes
28+
NOT_CRAN: true
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: r-lib/actions/setup-pandoc@v2
34+
35+
- uses: r-lib/actions/setup-r@v2
36+
with:
37+
r-version: ${{ matrix.config.r }}
38+
use-public-rspm: true
39+
40+
- name: Install system dependencies (Linux)
41+
if: runner.os == 'Linux'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y \
45+
libcurl4-openssl-dev \
46+
libssl-dev \
47+
libxml2-dev \
48+
libharfbuzz-dev \
49+
libfribidi-dev \
50+
libgit2-dev \
51+
libgsl-dev
52+
53+
- name: Install system dependencies (macOS)
54+
if: runner.os == 'macOS'
55+
run: |
56+
brew install gsl
57+
58+
- uses: r-lib/actions/setup-r-dependencies@v2
59+
with:
60+
extra-packages: any::rcmdcheck, any::devtools
61+
needs: check
62+
63+
- name: Check package
64+
uses: r-lib/actions/check-r-package@v2
65+
with:
66+
upload-snapshots: true
67+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
68+
69+
- name: Show testthat output
70+
if: always()
71+
run: |
72+
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
73+
shell: bash
74+
75+
- name: Upload check results
76+
if: failure()
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
80+
path: check
81+
82+
lint:
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- uses: r-lib/actions/setup-r@v2
89+
with:
90+
use-public-rspm: true
91+
92+
- uses: r-lib/actions/setup-r-dependencies@v2
93+
with:
94+
extra-packages: any::lintr, local::.
95+
needs: lint
96+
97+
- name: Lint
98+
run: |
99+
# Only lint if lintr is available (it's in Suggests)
100+
if (requireNamespace("lintr", quietly = TRUE)) {
101+
lintr::lint_package()
102+
} else {
103+
cat("lintr not available, skipping lint check\n")
104+
}
105+
shell: Rscript {0}
106+
107+
test-coverage:
108+
runs-on: ubuntu-latest
109+
110+
steps:
111+
- uses: actions/checkout@v4
112+
113+
- uses: r-lib/actions/setup-r@v2
114+
with:
115+
use-public-rspm: true
116+
117+
- uses: r-lib/actions/setup-r-dependencies@v2
118+
with:
119+
extra-packages: any::covr, local::.
120+
needs: coverage
121+
122+
- name: Test coverage
123+
run: |
124+
if (requireNamespace("covr", quietly = TRUE)) {
125+
covr::codecov(
126+
quiet = FALSE,
127+
clean = FALSE,
128+
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
129+
)
130+
} else {
131+
cat("covr not available, skipping coverage\n")
132+
}
133+
shell: Rscript {0}

.lintr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
linters: with_defaults(
2-
assignment_linter = NULL
3-
)
1+
linters: linters_with_defaults(line_length_linter(120), assignment_linter = NULL, object_name_linter = NULL, object_usage_linter = NULL)
2+
exclusions: c("R/RcppExports.R", "tests/testthat.R")

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Imports:
2424
caret,
2525
crayon,
2626
cvAUC,
27+
data.table,
2728
doParallel,
2829
dplyr,
2930
foreach,
@@ -45,7 +46,6 @@ Imports:
4546
tmle,
4647
weights
4748
Suggests:
48-
data.table,
4949
glmnet,
5050
lintr,
5151
MASS,

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ importFrom(caret,findLinearCombos)
5959
importFrom(crayon,bold)
6060
importFrom(crayon,red)
6161
importFrom(cvAUC,ci.cvAUC)
62+
importFrom(data.table,copy)
6263
importFrom(dplyr,group_by_at)
6364
importFrom(dplyr,summarize)
6465
importFrom(future.apply,future_lapply)
@@ -89,6 +90,7 @@ importFrom(stats,median)
8990
importFrom(stats,model.matrix)
9091
importFrom(stats,model.matrix.lm)
9192
importFrom(stats,na.omit)
93+
importFrom(stats,plogis)
9294
importFrom(stats,pnorm)
9395
importFrom(stats,predict)
9496
importFrom(stats,qnorm)

R/categoricals_to_factors.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ categoricals_to_factors = function(data, categoricals,
2020
}
2121

2222
# Use [[]] to support tibbles.
23-
if (class(data[[var_name]]) == "factor") {
23+
if (inherits(data[[var_name]], "factor")) {
2424
if (verbose) {
2525
cat("Skipping", var_name, "- already a factor.\n")
2626
}

R/create_dataset.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ create_dataset = function(data, varsX = "", varY = "",
177177
}
178178

179179
# Make sure Y is numeric and not a factor.
180-
if (class(Y) == "factor") {
180+
if (inherits(Y, "factor")) {
181181
cat("Converting Y from a factor to numeric.\n")
182182
# Y should be 0/1
183183
newY = as.numeric(Y) - 1

R/factors_to_indicators.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
#' @param max_levels If a factor contains more than this many levels, issue
1212
#' a warning and don't convert it to indicators.
1313
#' @param verbose TBD
14-
#' @param tolower If TRUE, lowercase new indicator names (FALSE by default).
14+
#' @param to_lower If TRUE, lowercase new indicator names (FALSE by default).
1515
#' @param data.table If TRUE, return a data.table (possibly faster).
1616
#' @importFrom stats model.matrix.lm
1717
#' @importFrom future.apply future_lapply
18+
#' @importFrom data.table copy
1819
#' @export
1920
factors_to_indicators =
2021
function(data, predictors = colnames(data), max_levels = 200L, verbose = FALSE,

0 commit comments

Comments
 (0)