Building multiple R lines

I have the following data:

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 

For each dim value, I want two lines. On one line an error is displayed where is.init = T, and the second line shows an error when is.init = F. The X axis is a bucket. It would be nice if all the lines "is.init = T", for example, are broken. How should I do it? Thanks in advance.

-one
source share
2 answers

Sort of:

 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) 

graph w faceting!

I found the almost exact plot you need here .

+1
source

This question is duplicated, but I'm trying to add a lattice solution. I found that there is no need to customize panel panels. Maybe I missed something, but here is my code:

 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])) }) 

enter image description here

+2
source

Source: https://habr.com/ru/post/1498377/


All Articles