-1

我有以下数据:

   dim   tuples buckets error is.init
1    5 13500000      50  0.29    TRUE
2    5 13500000     100  0.28    TRUE
3    5 13500000     150  0.27    TRUE
4    5 13500000     200  0.26    TRUE
5    5 13500000     250  0.26    TRUE
6    4   360000      50  0.10    TRUE
7    4   360000     100  0.09    TRUE
8    4   360000     150  0.09    TRUE
9    4   360000     200  0.09    TRUE
10   4   360000     250  0.09    TRUE
11   3     9000      50  0.10    TRUE
12   3     9000     100  0.09    TRUE
13   3     9000     150  0.09    TRUE
14   3     9000     200  0.08    TRUE
15   3     9000     250  0.07    TRUE
16   5 13500000      50  0.48   FALSE
17   5 13500000     100  0.43   FALSE
18   5 13500000     150  0.44   FALSE
19   5 13500000     200  0.44   FALSE
20   5 13500000     250  0.43   FALSE
21   4   360000      50  0.41   FALSE
22   4   360000     100  0.39   FALSE
23   4   360000     150  0.36   FALSE
24   4   360000     200  0.37   FALSE
25   4   360000     250  0.35   FALSE
26   3     9000      50  0.31   FALSE
27   3     9000     100  0.26   FALSE
28   3     9000     150  0.25   FALSE
29   3     9000     200  0.22   FALSE
30   3     9000     250  0.20   FALSE

对于每个暗淡值,我想要两行。第一行在 is.init = T 时显示错误,第二行在 is.init=F 时显示错误。X 轴是“桶”。例如,如果所有行“is.init = T”都是虚线,那就太好了。我该怎么做呢?提前致谢。

4

2 回答 2

2

这个问题是重复的,但是我尝试添加一个lattice解决方案,我发现自定义条形面板并不明显。也许我错过了一些东西,但这里是我的代码:

library(lattice) 
xyplot(error~buckets|dim,
       groups=is.init,data=dat,type='l',
       auto.key=list(columns = 2),
       strip = function(which.panel,var.name,factor.levels,...)
       {
         strip.default(..., which.panel,factor.levels,
                       var.name = paste0(var.name,factor.levels[which.panel]))
       })

在此处输入图像描述

于 2013-06-21T12:33:13.130 回答
1

就像是:

library(ggplot2)
library(reshape2)
w$new <- paste(w$is.init, w$dim, sep = ".") # I named your data frame w
ggplot(data = w, aes(x = buckets, y = error, group = new)) +
geom_line(aes(linetype = is.init), size = 1) + facet_wrap(~dim)

图 w 刻面!

我在这里找到了您需要的几乎确切的情节。

于 2013-06-21T13:03:29.810 回答