-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BHGC Website GHA Workflow Runner
committed
Dec 14, 2023
1 parent
47e08ec
commit 72e976c
Showing
7 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Marshalling of an R objects | ||
#' | ||
#' @param x | ||
#' An R object. | ||
#' | ||
#' @param \dots Not used. | ||
#' | ||
#' @return | ||
#' A `marshalled` object as described in [marshal()]. | ||
#' | ||
#' @details | ||
#' This is the default, fallback method for marshalling of an | ||
#' \R object. It assumes that the object do not need specific | ||
#' marshalling, but can be serialized as-is. All this default | ||
#' method does is wrapping the original object up in a | ||
#' `marshalled` object, so that the original object can be | ||
#' recovered via `unmarshalled()`. | ||
#' | ||
#' @example incl/marshal.default.R | ||
#' | ||
#' @rdname marshal.default | ||
#' @aliases marshal.default | ||
#' @export | ||
marshal.default <- function(x, ...) { | ||
res <- list( | ||
marshalled = x | ||
) | ||
class(res) <- marshal_class(x) | ||
|
||
res[["unmarshal"]] <- unmarshal_default | ||
|
||
res | ||
} | ||
|
||
|
||
unmarshal_default <- function(x, ...) { | ||
res <- x[["marshalled"]] | ||
stopifnot(all.equal(class(res), marshal_unclass(x), check.attributes = FALSE)) | ||
res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
x <- data.frame(a = 1:3, b = letters[1:3]) | ||
x_ <- marshal(x) | ||
x2 <- unmarshal(x_) | ||
stopifnot(identical(x2, x)) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
library(marshal) | ||
|
||
objects <- list( | ||
1:3, | ||
rnorm(3), | ||
as.list(1:3), | ||
data.frame(a = 1:3, b = letters[1:3]) | ||
) | ||
|
||
for (x in objects) { | ||
x_ <- marshal(x) | ||
x2 <- unmarshal(x_) | ||
stopifnot(identical(x2, x)) | ||
} | ||
|