Skip to content

Commit

Permalink
as.data.frame.sim
Browse files Browse the repository at this point in the history
  • Loading branch information
kkholst committed Feb 3, 2024
1 parent d69b7f1 commit a56dd06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ S3method(adjMat,lvm)
S3method(adjMat,lvmfit)
S3method(ancestors,lvm)
S3method(ancestors,lvmfit)
S3method(as.data.frame,sim)
S3method(as.matrix,sim)
S3method(as.vector,sim)
S3method(baptize,lvm)
Expand Down
9 changes: 7 additions & 2 deletions R/sim.default.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,19 @@ as.vector.sim <- function(x, mode="any") {
}

##' @export
as.matrix.sim <- function(x, ...) {
class(x) <- "matrix"
as.data.frame.sim <- function(x, ...) {
class(x) <- "data.frame"
attr(x, "call") <- NULL
attr(x, "f") <- NULL
attr(x, "time") <- NULL
return(x)
}

##' @export
as.matrix.sim <- function(x, ...) {
as.data.frame(x) |> as.matrix()
}

##' @export
"[.sim" <- function(x, i, j, drop = FALSE) {
atr <- attributes(x)
Expand Down

0 comments on commit a56dd06

Please sign in to comment.