鉴于来自更大数据集的以下几行数据,ggplot正在破碎。
Title - Year - Rated - Released - Budget-Gross #60 other columns
13 Alone in the Dark 1998 R 2005-01-28 2e7 8178569
21 Are We There Yet? 1998 PG 2005-01-21 2e7 98114471
我可以使用的唯一图表是geom_point
,但添加geom_smooth
会导致错误:ggplot(df, aes(x=Budget,y=Gross)) + geom_point() + geom_smooth()
错误为Error in split.default(x, g) : factor has bad level
完整的追溯:
29.
split.default(x, g)
28.
split(x, g)
27.
lapply(split(x, g), FUN)
26.
stats::ave(seq_len(nrow(munched)), munched$group, FUN = length)
25.
f(...)
24.
GeomLine$draw_panel(path, panel_scales, coord)
23.
gList(if (has_ribbon) GeomRibbon$draw_group(ribbon, panel_scales, coord), GeomLine$draw_panel(path, panel_scales, coord))
22.
f(...)
21.
self$draw_group(group, panel_scales, coord, ...)
20.
FUN(X[[i]], ...)
19.
lapply(groups, function(group) { self$draw_group(group, panel_scales, coord, ...) })
18.
f(..., self = self)
17.
(structure(function (...) f(..., self = self), class = "ggproto_method"))(data, panel_scales, coord)
16.
do.call(self$draw_panel, args)
15.
.fun(piece, ...)
14.
(function (i) { piece <- pieces[[i]] if (.inform) { ...
13.
loop_apply(n, do.ply)
12.
llply(.data = pieces, .fun = .fun, ..., .progress = .progress, .inform = .inform, .parallel = .parallel, .paropts = .paropts)
11.
plyr::dlply(data, "PANEL", function(data) { if (empty(data)) return(zeroGrob()) panel_scales <- layout$panel_ranges[[data$PANEL[1]]] ...
10.
f(..., self = self)
9.
self$geom$draw_layer(data, self$geom_params, layout, coord)
8.
f(..., self = self)
7.
l$draw_geom(d, layout, plot$coordinates)
6.
(function (l, d) l$draw_geom(d, layout, plot$coordinates))(dots[[1L]][[2L]], dots[[2L]][[2L]])
5.
mapply(FUN = f, ..., SIMPLIFY = FALSE)
4.
Map(function(l, d) l$draw_geom(d, layout, plot$coordinates), plot$layers, data)
3.
ggplot_gtable(data)
2.
print.ggplot(x)
1.
function (x, ...) UseMethod("print")(x)
不知道这里出了什么问题,有什么想法吗?我在ggplot中使用了正确的数据框和正确的列名。
> dput(head(df7, 29)) #https://pastebin.com/ct9XSqG7