在facet\u wrap/facet\u grid对象的每一帧上显示数据点的问题

在facet\u wrap/facet\u grid对象的每一帧上显示数据点的问题,r,ggplot2,facet,facet-wrap,facet-grid,R,Ggplot2,Facet,Facet Wrap,Facet Grid,我尝试使用facet_wrap或facet_grid(此时没有首选项)生成一个绘图,但在facet_wrap/facet_grid对象中的每个帧上显示一个数据点的选择 我读到,你可以简单地从数据集中删除facetting变量,你想包括在每个绘图中,但无论出于什么原因,这似乎不适合我 这在Rstudio版本1.1.453上 我发现这个代码示例: ggplot(mpg, aes(displ, hwy)) + geom_point(data = transform(mpg, class = NUL

我尝试使用facet_wrap或facet_grid(此时没有首选项)生成一个绘图,但在facet_wrap/facet_grid对象中的每个帧上显示一个数据点的选择

我读到,你可以简单地从数据集中删除facetting变量,你想包括在每个绘图中,但无论出于什么原因,这似乎不适合我

这在Rstudio版本1.1.453上

我发现这个代码示例:

ggplot(mpg, aes(displ, hwy)) +
  geom_point(data = transform(mpg, class = NULL), colour = "grey85") +
  geom_point() +
  facet_wrap(~class)
我在下面的代码中复制了它。上面的代码工作正常,但在我的实现中,无论出于何种原因,它都会返回一条错误消息。注意,我也尝试过将geom特性设置为geom_点,但没有成功

ggplot(data = Total, aes(Total$Time, Total$Killing)) + 
  geom_jitter(data = transform(Total, Run = NULL), colour = "grey85") +
  geom_point() + 
  facet_wrap(~Run)
错误:长度必须为1或与数据(2700)相同:x,y

这是我在尝试运行此代码时遇到的错误消息

最终,我的目标是运行下面的代码,但出于上述问题的目的,我对其进行了一些简化

ggplot(data = filter(Total, Cell_Line != "stDev"), aes(x= Time, y=Killing)) + 

  geom_line(data = filter(select(Total, -Run), Cell_Line == "Wild_Type"), aes(x = Time, y = filter(Total, Cell_Line == "Wild_Type")[,3])) +

  geom_errorbar(aes(x = filter(Total, Cell_Line == "Wild_Type")[,2], ymax = filter(Total, Cell_Line == "Wild_Type")[,3] + filter(Total, Cell_Line == "stDev")[,3], ymin = filter(Total, Cell_Line == "Wild_Type")[,3] - filter(Total, Cell_Line == "stDev")[,3])) +

  geom_point() + 

  facet_wrap(~Run)
以下是dput(总计)缩减到前30行的结果:

structure(list(Cell_Line = structure(c(5L, 12L, 13L, 1L, 2L, 
3L, 4L, 6L, 7L, 8L, 9L, 10L, 11L, 15L, 14L, 5L, 12L, 13L, 1L, 
2L, 3L, 4L, 6L, 7L, 8L, 9L, 10L, 11L, 15L, 14L), .Label = c("17", 
"19", "20", "29", "3", "33", "38", "47", "49", "53", "55", "7", 
"8", "stDev", "Wild_Type"), class = "factor"), Time = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("00", 
"02", "04", "08", "12", "18", "24", "32", "40", "48", "56", "64", 
"72", "80"), class = "factor"), Killing = c(0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0704388, 0.2881066, -0.0132908, 
0.04700991, 0.03049371, -0.02243472, 0.1513817, 0.129636, 0.09328508, 
0.05876777, 0.1063291, 0.0357473, 0.1974026, 0.07732854, 0.07383331
)), row.names = c(NA, 30L), class = "data.frame")

调用
transform
时出错:没有名为
Run
的列

set.seed(1)
Total$Run <- sample(1:100, 30)

# this is your own code:
ggplot(data = Total, aes(Total$Time, Total$Killing)) + 
  geom_jitter(data = transform(Total, Run = NULL), colour = "grey85") +
  geom_point() + 
  facet_wrap(~Run)
set.seed(1)

Total$Run您对
transform
的调用有一个错误:您没有名为
Run
的列

set.seed(1)
Total$Run <- sample(1:100, 30)

# this is your own code:
ggplot(data = Total, aes(Total$Time, Total$Killing)) + 
  geom_jitter(data = transform(Total, Run = NULL), colour = "grey85") +
  geom_point() + 
  facet_wrap(~Run)
set.seed(1)

总计$Run您能与我们共享您的数据吗?您可以使用
dput(Total)
(也许最好先缩短数据帧)来实现这一点。不要在
aes()
中使用
$
。您对第一个代码示例中的$的看法是正确的,一旦我删除了它们,它就起作用了!但我仍然无法执行底部较长的代码段。有什么想法吗?谢谢不要在
aes
中进行过滤,要么在
数据
参数中进行过滤,要么在
数据
参数中进行过滤。您的玩具数据没有任何名为
运行
的列。您如何假装将其用作转换的参数?您是否能够与我们共享您的数据?您可以使用
dput(Total)
(也许最好先缩短数据帧)来实现这一点。不要在
aes()
中使用
$
。您对第一个代码示例中的$的看法是正确的,一旦我删除了它们,它就起作用了!但我仍然无法执行底部较长的代码段。有什么想法吗?谢谢不要在
aes
中进行过滤,要么在
数据
参数中进行过滤,要么在
数据
参数中进行过滤。您的玩具数据没有任何名为
运行
的列。如何假装将其用作变换的参数?