【问题标题】:ggmosaic error message: default method not implemented for type 'list'ggmosaic 错误消息:未为类型“列表”实现默认方法
【发布时间】:2017-10-21 10:52:24
【问题描述】:

尝试使用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

即使是小插图中的示例对我来说也失败了。

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 版本之前的最新版本,ggmosaic Ver 0.1.2

我要使用的虚构数据框是

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"))

这段代码没有成功:

ggplot(diverse) +
  geom_mosaic(aes(weight = 1, x = product(JrAssoc, SrAssPtr), fill = Diversity))

感谢您的指导。

【问题讨论】:

标签: ggplot2 mosaic-plot ggmosaic


【解决方案1】:

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

devtools::install_github('cran/ggplot2')

您的问题应该得到解决。

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

【讨论】:

  • > devtools::install_github('cran/ggplot2') 安装失败:SSL CA 证书有问题(路径?访问权限?)
  • 嗯……奇怪!你能用 install_github 安装任何其他库吗?
猜你喜欢
  • 2019-11-25
  • 1970-01-01
  • 2020-11-02
  • 2022-10-13
  • 2015-12-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多