首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ggmosaic错误消息:未为类型'list‘实现默认方法

ggmosaic错误消息:未为类型'list‘实现默认方法
EN

Stack Overflow用户
提问于 2017-05-22 04:55:59
回答 1查看 2.5K关注 0票数 0

尝试使用ggmosaic创建热图时,一直收到错误Error in is.finite(x) : default method not implemented for type 'list'

在搜索该错误消息时,一个答案是“这个错误是因为is.infinite()和is.finite()函数没有使用data.frames的方法实现。”But not a useful solution in the question nor about ggmosaic

即使是小插曲中的例子对我来说也是失败的。

代码语言:javascript
复制
ggplot(data = NHANES) +
   geom_mosaic(aes(weight = Weight, x = product(SleepHrsNight), fill=factor(SleepHrsNight)), na.rm=TRUE) +
   labs(x="Hours of sleep a night ", title='f(SleepHrsNight)') + guides(fill=guide_legend(title = "SleepHrsNight", reverse = TRUE))

我的系统是Windows,RStudio,R版本1之前的最新版本,以及ggmosaic版本0.1.2

我想要使用的虚构数据框是

代码语言:javascript
复制
structure(list(Diversity = structure(c(1L, 5L, 4L, 5L, 1L, 2L, 
2L, 2L, 4L, 1L, 5L, 4L, 5L, 4L, 2L, 3L, 3L, 1L, 5L, 2L, 1L, 4L, 
3L, 3L, 3L), .Label = c("AfricanAm", "Asian", "Cauc.", "Latino", 
"Other"), class = "factor"), Office = structure(c(1L, 2L, 1L, 
3L, 4L, 5L, 2L, 4L, 5L, 3L, 4L, 4L, 1L, 2L, 3L, 4L, 1L, 5L, 5L, 
1L, 2L, 3L, 2L, 3L, 5L), .Label = c("Hamlet", "MainTown", "Metroprole", 
"Smithville", "Urbanburg"), class = "factor"), JrAssoc = c(1, 
1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 1, 1, 1, 2, 2, 3, 3, 3, 5, 5, 2, 
5, 9, 10), SrAssPtr = c(2, 2, 1, 1, 3, 2, 1, 4, 4, 5, 1, 1, 3, 
5, 7, 3, 2, 1, 1, 1, 1, 2, 3, 4, 4)), row.names = c(NA, -25L), .Names = c("Diversity", 
"Office", "JrAssoc", "SrAssPtr"), class = c("tbl_df", "tbl", 
"data.frame"))

此代码未成功:

代码语言:javascript
复制
ggplot(diverse) +
  geom_mosaic(aes(weight = 1, x = product(JrAssoc, SrAssPtr), fill = Diversity))

感谢您的指导。

EN

回答 1

Stack Overflow用户

发布于 2017-06-26 16:45:39

如果您只是以这种方式更新ggplot2库

代码语言:javascript
复制
devtools::install_github('cran/ggplot2')

你的问题应该得到解决。

正如在我的comments中提到的,作者正在尝试解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44101713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档