Comments (4)
It's actually the readr package that adds the problems
attribute. From help("problems", package = "readr")
:
"Readr functions will only throw an error if parsing fails in an unrecoverable way. However, there are lots of potential problems that you might want to know about - these are stored in the problems
attribute of the output ..."
from marshal.
marshal()
on a tbl
object could simply drop the problems
attribute.
from marshal.
marshal()
on atbl
object could simply drop theproblems
attribute.
Ah, the problems
attribute may also contain non-pointer objects, so we don't always have to drop it. For example,
> x <- parse_integer(c("1X", "blah", "3"))
Warning: 2 parsing failures.
row col expected actual
1 -- no trailing characters 1X
2 -- no trailing characters blah
> str(x)
int [1:3] NA NA 3
- attr(*, "problems")= tibble [2 × 4] (S3: tbl_df/tbl/data.frame)
..$ row : int [1:2] 1 2
..$ col : int [1:2] NA NA
..$ expected: chr [1:2] "no trailing characters" "no trailing characters"
..$ actual : chr [1:2] "1X" "blah"
More clues about alternatives can be found in:
readr:::problems
function (x = .Last.value)
{
problems <- probs(x)
if (is.null(problems)) {
return(invisible(no_problems))
}
if (inherits(problems, "tbl_df")) {
return(problems)
}
vroom::problems(x)
}
So, it looks like vroom might be involved too;
> vroom::problems
function (x = .Last.value, lazy = FALSE)
{
if (!inherits(x, "tbl_df")) {
cli::cli_abort(c("The {.arg x} argument of {.fun vroom::problems} must be a data frame created by vroom:",
x = "{.arg x} has class {.cls {class(x)}}"))
}
if (!isTRUE(lazy)) {
vroom_materialize(x, replace = FALSE)
}
probs <- attr(x, "problems")
if (typeof(probs) != "externalptr") {
cli::cli_abort(c("The {.arg x} argument of {.fun vroom::problems} must be a data frame created by vroom:",
x = "{.arg x} seems to have been created with something else, maybe readr?"))
}
probs <- vroom_errors_(probs)
probs <- probs[!duplicated(probs), ]
probs <- probs[order(probs$file, probs$row, probs$col), ]
tibble::as_tibble(probs)
}
<environment: namespace:vroom>
from marshal.
From the above, marshalling of tbl_df
(sic!) could rely on the following "pruning" method:
prune.tbl_df <- function(x, ...) {
problems <- attr(x, "problems", exact = TRUE)
## Materialize `problems` stored elsewhere in this process?
if (typeof(problems) == "externalptr") {
problems <- vroom::problems(x)
attr(x, "problems") <- problems
}
x
}
Comment: We could use NextMethod("prune")
at the end.
Comment 2: We've punted on the idea of having prune()
methods thus far, but maybe this is an argument for having them. Maybe it should be names something else than "prune", because pruning could also mean "drop unnecessary content".
from marshal.
Related Issues (14)
- Package 'marshal': serialize objects HOT 3
- marshal: turn connections into invalid connections HOT 1
- marshal: Rcpp::sourceCpp() HOT 1
- Add can_be_marshalled() HOT 2
- Use cases: Implement marshal()/unmarshal() based on bundle::bundle() S3 methods HOT 1
- Update README - it's really outdated HOT 1
- DESIGN: Should marshal(x) be able to return `x` as-is? HOT 1
- DESIGN: What should the default unmarshal(x) do - return `x` as-is?
- Plan for CRAN release HOT 2
- DESIGN: Save package (versions) instead of unmarshal function
- DESIGN: `clone` / `inplace` argument
- DESIGN: global state dict HOT 4
- Table of "known cases"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marshal.