在 R 中绘制数据;错误:未为“列表”类型实现默认方法

Ali*_*ina 7 plot r ggplot2

我正在尝试在 ggplot 中绘制数据(我也尝试了来自 github 的 CRAN 版本),但最终出现错误:

Error in is.finite(x) : default method not implemented for type 'list'
Run Code Online (Sandbox Code Playgroud)

这是情节的代码:

ggplot(SinglePatient, aes(x = Condition, y = new, fill = Session)) +
  stat_summary(fun.y = mean, geom = "bar", color = 'black', size = 1, position = "dodge") +
  stat_summary(fun.data = mean_se, geom ="errorbar", width = .1, size = 1, position = position_dodge(width=.9))+
  xlab("Condition") + ylab("Reaction time (ms)") +
  scale_y_continuous(expand = c(0,0)) +
  plot_theme
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的 data.frame 中的数据示例:


Patient  Session   Stimulus     Trial  Running[Trial]   Block   ACC     Side   Condition  Group  new.RT
7212      post      blue_color.jpg  14  Center2ExpTrialList 2   incorrect   L   Center2Exp  BrainHQ  251    
7212      post      brown_color.jpg 6   Center2ExpTrialList 2   correct     R   Center2Exp  BrainHQ  253
7212      post      blue_color.jpg  19  Center2ExpTrialList 2   correct     L   Center2Exp  BrainHQ  256
7212      post      brown_color.jpg 23  Center2ExpTrialList 12  correct     R   Center2Exp  BrainHQ  261    
7212      post      blue_color.jpg  18  Center2ExpTrialList 2   correct     L   Center2Exp  BrainHQ  267    
Run Code Online (Sandbox Code Playgroud)

知道我需要改变什么吗?非常感谢您的参与。

小智 6

我遇到此问题时的解决方案是unlist在您提供给 ggplot 的列上运行。问题似乎是 ggplot 不想绘制列表的东西,并且下载最新版本的 ggplot 也没有解决问题。您可能无意中将您提供给它的数据列在了列表中。

我通过简单地执行以下操作解决了这个问题:

dataframe$column <- unlist(dataframe$column)

问题:数据以某种方式采用列表格式。

解决方案: unlist()