Skip to content

Commit d3c4d35

Browse files
authored
Merge pull request #233 from bpbond/gp
Good-practice changes
2 parents b57ea57 + eb739ac commit d3c4d35

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ Encoding: UTF-8
2828
LazyData: true
2929
RoxygenNote: 7.0.2
3030
VignetteBuilder: knitr
31+
URL: https://github.com/bpbond/cosore
32+
BugReports: https://github.com/bpbond/cosore/issues

R/parser.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ read_contributors_file <- function(dataset_name, file_data = NULL) {
186186
stop(dataset_name, ": email for primary contributor is missing")
187187
}
188188
# Check for invalid email addresses
189-
eml <- sapply(strsplit(cfd$CSR_EMAIL, ";"), function(x) x[1])
189+
eml <- vapply(strsplit(cfd$CSR_EMAIL, ";"), function(x) x[1], FUN.VALUE = character(1))
190190
# \p{L} matches all Perl letters; we need this for diacriticals etc.
191191
invalid_emails <- grep("^[0-9\\p{L}._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$",
192192
eml, ignore.case = TRUE, invert = TRUE, perl = TRUE)

R/utils.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ rbind_list <- function(x) {
147147
if(length(x) == 0) return(tibble())
148148

149149
# Everything in x has to be data.frame-equivalent or NULL
150-
stopifnot(all(sapply(x, function(x) {
150+
stopifnot(all(vapply(x, function(x) {
151151
any(c("data.frame", "NULL") %in% class(x))
152152
}
153-
)))
153+
, FUN.VALUE = logical(1))))
154154

155155
all_names <- unique(unlist(lapply(x, function(x) names(x))))
156156

@@ -160,8 +160,9 @@ rbind_list <- function(x) {
160160
if(is.null(x_entry)) {
161161
data.frame()
162162
} else {
163-
data.frame(c(x_entry, sapply(setdiff(all_names, names(x_entry)),
164-
function(y) NA)),
163+
data.frame(c(x_entry, vapply(setdiff(all_names, names(x_entry)),
164+
function(y) NA,
165+
FUN.VALUE = logical(1))),
165166
check.names = FALSE, stringsAsFactors = FALSE)
166167
}
167168
}), make.row.names = FALSE, stringsAsFactors = FALSE))
@@ -601,7 +602,7 @@ remove_invalid_timestamps <- function(dsd, tf, tz) {
601602
#' @keywords internal
602603
remove_empty_columns <- function(x) {
603604
stopifnot(is.data.frame(x))
604-
all_na <- sapply(x, function(x) all(is.na(x)))
605+
all_na <- vapply(x, function(x) all(is.na(x)), FUN.VALUE = logical(1))
605606
x[!all_na]
606607
}
607608

essd/essd_ms.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ Missing values are encoded by a blank (i.e. two successive commas in the CSV for
140140
A release download is fully self-contained, with full data, metadata, and documentation; a file manifest; a copy of the data license; an introductory vignette; a summary report on the entire database; and an explanatory README with links to this publication.
141141

142142
```{r dbsize, include=FALSE, cache=TRUE}
143-
db_memsize <- sum(sapply(db$CSR_DATASET, function(x) object.size(csr_dataset(x)$data))) / 1e6
143+
db_memsize <- sum(vapply(db$CSR_DATASET, function(x) object.size(csr_dataset(x)$data),
144+
FUN.VALUE = numeric(1))) / 1e6
144145
db_disksize <- system2("git",
145146
args = c("count-objects", "-vH"),
146147
stdout = TRUE)

0 commit comments

Comments
 (0)