Add as.data.frame method to mapped_discrete that strips the class so that recycling is possible

This commit is contained in:
Thomas Lin Pedersen 2020-05-28 09:04:48 +02:00
parent f802c5e7ec
commit 1f1e785ac7
No known key found for this signature in database
GPG Key ID: E85D3C27C0D92AD3
3 changed files with 6 additions and 0 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ revdep/library
revdep/checks.noindex
revdep/library.noindex
revdep/data.sqlite
revdep/cloud.noindex

View File

@ -11,6 +11,7 @@ S3method("[<-",uneval)
S3method("[[",ggproto)
S3method("[[<-",uneval)
S3method(.DollarNames,ggproto)
S3method(as.data.frame,mapped_discrete)
S3method(as.list,ggproto)
S3method(autolayer,default)
S3method(autoplot,default)

View File

@ -157,3 +157,7 @@ c.mapped_discrete <- function(..., recursive = FALSE) {
value <- as.numeric(unclass(value))
new_mapped_discrete(NextMethod())
}
#' @export
as.data.frame.mapped_discrete <- function (x, ..., stringsAsFactors = default.stringsAsFactors()) {
as.data.frame.vector(x = unclass(x), ..., stringsAsFactors = stringsAsFactors)
}