Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/compression.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ parse_archive <- function(file, which, file_type, ...) {
extract_func(file, files = file_list[which], exdir = d)
return(file.path(d, file_list[which]))
}
if (substring(which, 1, 1) != "^") {
if (!startsWith(which, "^")) {
which2 <- paste0("^", which)
}
extract_func(file, files = file_list[grep(which2, file_list)[1]], exdir = d)
Expand Down Expand Up @@ -137,8 +137,8 @@ parse_archive <- function(file, which, file_type, ...) {

.get_compressed_format <- function(cfile, file, file_type, format) {
if (file_type %in% c("gzip", "bzip2")) {
return(ifelse(isFALSE(missing(format)), tolower(format), get_info(find_compress(cfile)$file)$input))
return(ifelse(!missing(format), tolower(format), get_info(find_compress(cfile)$file)$input))
}
## zip or tar formats, use the decompressed file path
return(ifelse(isFALSE(missing(format)), tolower(format), get_info(file)$input))
return(ifelse(!missing(format), tolower(format), get_info(file)$input))
}
2 changes: 1 addition & 1 deletion R/export_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export_delim <- function(file, x, fwrite = lifecycle::deprecated(), sep = "\t",

#' @export
.export.rio_rdata <- function(file, x, ...) {
if (isFALSE(is.data.frame(x)) && isFALSE(is.list(x)) && isFALSE(is.environment(x)) && isFALSE(is.character(x))) {
if (!(is.data.frame(x) || is.list(x) || is.environment(x) || is.character(x))) {
stop("'x' must be a data.frame, list, or environment")
}
if (is.data.frame(x)) {
Expand Down
2 changes: 1 addition & 1 deletion R/import_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import_delim <- function(file, which = 1, sep = "auto", header = "auto", strings
}

.fix_col_types <- function(col_types, widths) {
if (isFALSE(is.numeric(widths))) {
if (!is.numeric(widths)) {
return(col_types)
}
col_types <- rep("?", length(widths))
Expand Down
2 changes: 1 addition & 1 deletion R/remote_to_local.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ remote_to_local <- function(file, format) {
## try to extract format from headers: read #403 about whether this code is doing anything
h1 <- curl::parse_headers(u$headers)
## check `Content-Disposition` header
if (!any(grepl("^Content-Disposition", h1))) {
if (!any(startsWith(h1, "Content-Disposition"))) {
stop("Unrecognized file format. Try specifying with the format argument.")
}
h <- h1[grep("filename", h1, fixed = TRUE)]
Expand Down
2 changes: 1 addition & 1 deletion R/set_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set_class <- function(x, class = NULL) {
return(out)
}
if (!length(rownames(out))) {
rownames(out) <- as.character(seq_len(length(out[, 1L, drop = TRUE])))
rownames(out) <- as.character(seq_along(out[, 1L, drop = TRUE]))
}
return(out)
}
2 changes: 1 addition & 1 deletion R/suggestions.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uninstalled_formats <- function() {
show_unsupported_formats <- function() {
## default_formats <- sort(unique(rio_formats$format[rio_formats$type == "import"]))
suggested_formats <- rio_formats[rio_formats$type == "suggest",]
suggested_formats$pkg <- vapply(strsplit(suggested_formats$import_function, "::"), FUN = `[`, FUN.VALUE = character(1), 1)
suggested_formats$pkg <- vapply(strsplit(suggested_formats$import_function, "::", fixed = TRUE), FUN = `[`, FUN.VALUE = character(1), 1)
missing_pkgs <- uninstalled_formats()
suggested_formats$installed <- vapply(suggested_formats$pkg, function(x) x %in% missing_pkgs, logical(1), USE.NAMES = FALSE)
unsupported_formats <- suggested_formats[suggested_formats$installed,]
Expand Down
10 changes: 5 additions & 5 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ get_info <- function(file) {
if (tolower(file) == "clipboard") {
return(.query_format(input = "clipboard", file = "clipboard"))
}
if (isFALSE(R.utils::isUrl(file))) {
if (!R.utils::isUrl(file)) {
ext <- tolower(tools::file_ext(file))
} else {
parsed <- strsplit(strsplit(file, "?", fixed = TRUE)[[1]][1], "/", fixed = TRUE)[[1]]
Expand Down Expand Up @@ -90,16 +90,16 @@ escape_xml <- function(x, replacement = c("&amp;", "&quot;", "&lt;", "&gt;", "&a

.check_file <- function(file, single_only = TRUE) {
## check the `file` argument
if (isTRUE(missing(file))) { ## for the case of export(iris, format = "csv")
if (missing(file)) { ## for the case of export(iris, format = "csv")
return(invisible(NULL))
}
if (isFALSE(inherits(file, "character"))) {
if (!inherits(file, "character")) {
stop("Invalid `file` argument: must be character", call. = FALSE)
}
if (isFALSE(length(file) == 1) && single_only) {
if (length(file) != 1 && single_only) {
stop("Invalid `file` argument: `file` must be single", call. = FALSE)
}
if (any(is.na(file))) {
if (anyNA(file)) {
stop("Invalid `file` argument: `file` must not be NA", call. = FALSE)
}
invisible(NULL)
Expand Down
Loading