Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用“行”作为列名时发生ggplot facet\U wrap错误_R_Ggplot2_Data.table - Fatal编程技术网

使用“行”作为列名时发生ggplot facet\U wrap错误

使用“行”作为列名时发生ggplot facet\U wrap错误,r,ggplot2,data.table,R,Ggplot2,Data.table,我有一个data.table,我正试图用ggplot绘制面,我得到下面列出的错误。提前感谢您的帮助 require(data.table, ggplot2) dt <- as.data.table(read.table(h=T, text="ROW mode resbin V1 0 RD 50.0 0 1 RD 50.0 0 2 RD 50.0 0 0 RD 33.3 0 1 RD 33.3 0 1

我有一个data.table,我正试图用ggplot绘制面,我得到下面列出的错误。提前感谢您的帮助

require(data.table, ggplot2)

dt <- as.data.table(read.table(h=T, 
text="ROW mode resbin V1
0   RD   50.0  0
1   RD   50.0  0
2   RD   50.0  0
0   RD   33.3  0
1   RD   33.3  0                  
1   PV    7.5  1
2   PV    7.5  0
0   PV    6.0  1
1   PV    6.0  1
2   PV    6.0  1"))


ggplot(dt, aes(x = factor(resbin), y = V1, group=1)) + 
geom_point(aes(color=factor(mode)), size=3) +
geom_line() +
facet_wrap(~factor(ROW), ncol=2)

#Error in layout_base(data, vars, drop = drop) : 
#At least one layer must contain all variables used for facetting
require(data.table,ggplot2)

有些有趣的事情正在发生,我不完全理解。这似乎对我有用:

dt <- as.data.table(read.table(h=T, 
text="grp mode resbin V1
0   RD   50.0  0
1   RD   50.0  0
2   RD   50.0  0
0   RD   33.3  0
1   RD   33.3  0                  
1   PV    7.5  1
2   PV    7.5  0
0   PV    6.0  1
1   PV    6.0  1
2   PV    6.0  1"))


ggplot(dt, aes(x = factor(resbin), y = V1)) + 
geom_point(aes(color=factor(mode)), size=3) +
geom_line(aes(group = 1)) +
facet_wrap(~grp, ncol=2)

dt我试着把这个名字从“mode”改为“my.mode”,并去掉了一些因素,但它还是爆炸了。我还更喜欢使用as.data.frame()读取中的数据。这是一个很好的…它起作用了。谢谢你的帮助。我必须记住,ggplot不喜欢名为
ROW
@NathanG的列,因为我对列名非常怀疑。我打算四处询问以确认这是一个bug。它不喜欢的其他名称是
COL
PANEL
SCALE\ux
SCALE\uy
AXIS\ux
AXIS\uy
。看见