-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows for multiple tables per page #31
base: main
Are you sure you want to change the base?
Changes from 4 commits
ec78794
b591abf
70230cf
b2b0ad9
88df806
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,19 +58,29 @@ list_matrices <- function(tables, encoding = NULL, ...) { | |
if (nxt$size() == 0L) { | ||
break | ||
} | ||
tab <- nxt$get(0L) | ||
out[[n]] <- matrix(NA_character_, | ||
nrow = tab$getRows()$size(), | ||
ncol = tab$getCols()$size()) | ||
for (i in seq_len(nrow(out[[n]]))) { | ||
for (j in seq_len(ncol(out[[n]]))) { | ||
out[[n]][i, j] <- tab$getCell(i-1L, j-1L)$getText() | ||
outTab <- list() | ||
for(nTabs in seq_len(nxt$size())){ | ||
tab <- nxt$get(nTabs - 1L) | ||
outTab[[nTabs]] <- matrix(NA_character_, | ||
nrow = tab$getRows()$size(), | ||
ncol = tab$getCols()$size()) | ||
for (i in seq_len(nrow(outTab[[nTabs]]))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add comments indicating what's going on here? |
||
for (j in seq_len(ncol(outTab[[nTabs]]))) { | ||
outTab[[nTabs]][i, j] <- tab$getCell(i-1L, j-1L)$getText() | ||
} | ||
} | ||
if (!is.null(encoding)) { | ||
Encoding(outTab[[nTabs]]) <- encoding | ||
} | ||
rm(tab) | ||
} | ||
if (!is.null(encoding)) { | ||
Encoding(out[[n]]) <- encoding | ||
## Put outTab into out, depending on size | ||
if(nxt$size() == 1L){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spaces between brackets. |
||
out[[n]] <- outTab[[1]] | ||
} else { | ||
out[[n]] <- outTab | ||
} | ||
rm(tab) | ||
rm(outTab) | ||
n <- n + 1L | ||
} | ||
out | ||
|
@@ -79,18 +89,34 @@ list_matrices <- function(tables, encoding = NULL, ...) { | |
list_characters <- function(tables, sep = "\t", encoding = NULL, ...) { | ||
m <- list_matrices(tables, encoding = encoding, ...) | ||
lapply(m, function(x) { | ||
paste0(apply(x, 1, paste, collapse = sep), collapse = "\n") | ||
if(inherits(x, "matrix")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spaces between brackets. |
||
paste0(apply(x, 1, paste, collapse = sep), collapse = "\n") | ||
} else { | ||
lapply(x, function(y) paste0(apply(y, 1, paste, collapse = sep), | ||
collapse = "\n")) | ||
} | ||
}) | ||
} | ||
|
||
list_data_frames <- function(tables, sep = "\t", stringsAsFactors = FALSE, encoding = NULL, ...) { | ||
char <- list_characters(tables = tables, sep = sep, encoding = encoding) | ||
lapply(char, function(x) { | ||
o <- try(read.delim(text = x, stringsAsFactors = stringsAsFactors, ...)) | ||
if (inherits(o, "try-error")) { | ||
return(x) | ||
if(inherits(x, "character")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add spaces between brackets. |
||
o <- try(read.delim(text = x, stringsAsFactors = stringsAsFactors, ...)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this |
||
if (inherits(o, "try-error")) { | ||
return(x) | ||
} else { | ||
return(o) | ||
} | ||
} else { | ||
return(o) | ||
lapply(x, function(y){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add space between brackets. |
||
o <- try(read.delim(text = y, stringsAsFactors = stringsAsFactors, ...)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this |
||
if (inherits(o, "try-error")) { | ||
return(y) | ||
} else { | ||
return(o) | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces between brackets.