Skip to content

Commit cb53d80

Browse files
committed
fixed all R CMD check issues
1 parent 429aa9a commit cb53d80

11 files changed

+66
-17
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ README.Rmd
77
cran-comments.md
88
params.Rproj
99
^\.httr-oauth$
10+
^\.github$

.github/workflows/r-cmd-check.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
config:
26-
- {os: windows-latest, r: '4.0', vdiffr: true, xref: true}
27-
- {os: macOS-latest, r: '4.0', vdiffr: true, xref: true}
28-
- {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true}
29-
- {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
30-
- {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
3126
# skip a few R versions
27+
# - {os: windows-latest, r: '4.0', vdiffr: true, xref: true}
28+
# - {os: macOS-latest, r: '4.0', vdiffr: true, xref: true}
29+
# - {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true}
30+
- {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
31+
# - {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
3232
# - {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
3333
# - {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
3434
# - {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Suggests:
2020
License: GPL-2
2121
Authors@R: c(
2222
person("Sahil", "Seth", role = c("aut", "cre"), email = "[email protected]"),
23-
person("Yihui", "Xie", role = c("ctb"), comment = "kable from knitr R/table.R")
23+
person("Yihui", "Xie", role = c("ctb"), comment = "kable from knitr R/table.R")
2424
)
2525
URL: https://github.com/sahilseth/params
2626
BugReports: https://github.com/sahilseth/params/issues

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ importFrom(purrr,map2)
2020
importFrom(readr,write_delim)
2121
importFrom(tools,assertCondition)
2222
importFrom(tools,file_ext)
23+
importFrom(utils,head)
2324
importFrom(utils,read.table)
2425
importFrom(utils,write.table)

R/fix_column_names.R

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#'
1212
fix_names <- function (x, char = "_"){
1313

14+
x <- gsub("\\ ", "", as.character(x), fixed = TRUE)
1415
x <- gsub("_", char, as.character(x), fixed = TRUE)
1516
x <- gsub("-", char, as.character(x), fixed = TRUE)
1617
x <- gsub(" ", char, as.character(x), fixed = TRUE)
@@ -20,13 +21,23 @@ fix_names <- function (x, char = "_"){
2021
}
2122

2223

24+
#' fix_column_names
25+
#'
26+
#' removes special chars from names
27+
#'
28+
#' @param x a character vector
29+
#' @param char replace special characters with this symbol
30+
#'
2331
fix_column_names <- function(x, char = "_"){
24-
x %<>% strsplit(split = "\n") %>% unlist() %>%
25-
stringr::str_trim()
32+
x = strsplit(x, split = "\n")
33+
x = unlist(x)# %>%
34+
#stringr::str_trim()
2635

27-
x = fix_names(x, char) %>% make.names() %>% tolower()
36+
x = fix_names(x, char)
37+
x = make.names(x)
38+
x = tolower(x)
2839

29-
paste(x, collapse = "\n") %>% cat()
40+
cat(paste(x, collapse = "\n"))
3041
invisible(x)
3142
}
3243

R/load_opts.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
2+
#' @importFrom utils head
13
.remove_period_from_nms <- function(lst, verbose){
24
nms = names(lst)
35
vars_to_be_renamed = grep("\\.", nms, value = T)
46
if(length(vars_to_be_renamed) > 0){
57
if(verbose)
68
message("found . in some variable names, convering to _:\n",
7-
paste0(head(vars_to_be_renamed, 2), collapse = "\n"))
9+
paste0(utils::head(vars_to_be_renamed, 2), collapse = "\n"))
810

911
# append the list with new vars, with _ in their name
1012
newnms = gsub("\\.", "\\_", vars_to_be_renamed)

R/read_sheet.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#' @param ext determined using file extention. Specifying will override
2121
#'
2222
#' @param id_column all rows which have this column as blank are skipped. See details.
23-
#' @param ... passed onto read.xlsx of openxlsx, read.table or read.csv2 depending on the file type.
2423
#'
2524
#' @param start_row supplied to read.xlsx
2625
#' @param sheet supplied to read.xlsx, index or name of the sheet to be read from excel file. See \link[openxlsx]{read.xlsx}
@@ -30,6 +29,10 @@
3029
#' @param file write: output file name.
3130
#' @param verbose verbosity level.
3231
#'
32+
#' @param type in case of writing an xlsx file, should the data.frame to written as excel 'table'. ['table']
33+
#'
34+
#' @param ... passed onto read.xlsx of openxlsx, read.table or read.csv2 depending on the file type.
35+
#'
3336
#' @details
3437
#'
3538
#' \strong{Note: for excel sheets}:
@@ -60,6 +63,8 @@
6063
#'
6164
#' # write sheets -------
6265
#'
66+
#' \dontrun{
67+
#' # throws a R CMD check note - don't run
6368
#' ## write a comma seperated sheet
6469
#' write_sheet(sheet, "example.csv")
6570
#'
@@ -68,6 +73,7 @@
6873
#'
6974
#' ## write an excel seperated sheet
7075
#' write_sheet(sheet, "example.xlsx")
76+
#' }
7177
#'
7278
#' @export
7379
read_sheet <- function(x, id_column, start_row = 1,
@@ -103,7 +109,7 @@ read_sheet <- function(x, id_column, start_row = 1,
103109
stop("Sorry read_sheet does not recognize this file format: ", ext, " please use tsv, csv or xlsx (sheetname: sample_sheet)")
104110
}
105111

106-
### ------ remove blank rows and columns
112+
# remove blank rows and columns
107113
if(missing(id_column)) {
108114
id_column = 1
109115
if(verbose)

R/write_sheet.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ write_sheet <- function(x, file, ext, type = "", ...){
5252

5353

5454
write_sheets <- function(lst, file){
55-
wb <- createWorkbook()
56-
sheets <- lapply(names(lst), addWorksheet, wb = wb, gridLines = F)
57-
tmp = map2(names(lst), lst, writeDataTable, wb = wb, bandedRows = F, tableStyle = "TableStyleLight1")
58-
saveWorkbook(wb, file, overwrite = T)
55+
wb <- openxlsx::createWorkbook()
56+
sheets <- lapply(names(lst), openxlsx::addWorksheet, wb = wb, gridLines = F)
57+
tmp = map2(names(lst), lst, openxlsx::writeDataTable, wb = wb, bandedRows = F, tableStyle = "TableStyleLight1")
58+
openxlsx::saveWorkbook(wb, file, overwrite = T)
5959

6060
}
6161

man/fix_column_names.Rd

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/read_sheet.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_read_sheet.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# https://r-pkgs.org/data.html#data-extdata
2+
# Data for tests: it’s ok to put small files directly in your test directory.
3+
# But remember unit tests are for testing correctness, not performance, so keep the size small.
4+
#
5+
# Data for vignettes. If you want to show how to work with an already loaded dataset, put that data in data/.
6+
# If you want to show how to load raw data, put that data in inst/extdata.
7+
#
18

29

310
context("read_sheet")

0 commit comments

Comments
 (0)