From 2b040cda8e45c1c6b1853885704d0b6e2191dcc5 Mon Sep 17 00:00:00 2001 From: Schultheis Date: Wed, 16 Oct 2019 13:37:34 +0200 Subject: [PATCH] parser: devtools::check threw an error so empty columns will now be removed in a different more memory efficient way. --- R/parser.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/parser.R b/R/parser.R index c2ca756..6ad959e 100644 --- a/R/parser.R +++ b/R/parser.R @@ -365,7 +365,13 @@ parser <- function(file, dec = ".") { names(metadata) <- as.character(metadata[1]) # remove empty columns - metadata <- metadata[, which(unlist(lapply(metadata, function(x) !all(is.na(x) || x == "")))), with = FALSE] + empty_cols <- union( + which(colSums(is.na(metadata)) == nrow(metadata)), # indices of full na columns + which(colSums(metadata == "") == nrow(metadata)) # indices of full "" columns + ) + if (length(empty_cols) > 0) { + metadata[, (empty_cols) := NULL] + } # delete first line metadata <- metadata[-1]