Define a subpanel in an existing splom by clicking

I would like to be able to generate a basic splom graph in R, and then use the mouse to click on one of the sub-panels ( panel.pairs in particular) and return R either the coordinates of this sub-panel or, even better, the names of the corresponding variables built in this subpanet.

Here is an example splom to work with:

 require(lattice) data(iris) super.sym <- trellis.par.get("superpose.symbol") splom(~iris[1:4], groups = Species, data = iris, panel = panel.superpose, key = list(title = "Three Varieties of Iris", columns = 3, points = list(pch = super.sym$pch[1:3], col = super.sym$col[1:3]), text = list(c("Setosa", "Versicolor", "Virginica")))) 

Here I got the closest so far, which allows me to click on a point on one of the sub-panels and observe where this point appears in another place. I really don't want to, but it makes me believe it:

 trellis.focus() panel.link.splom() trellis.unfocus() #to close the trellis.focus session 
+4
source share
2 answers

You can use the option in more detail to get information:

  panel.link.splom(verbose=TRUE) 

you get to the console:

 Click to choose one point to highlight Sepal.Length Sepal.Width Petal.Length Petal.Width 141 6.7 3.1 5.6 2.4 

You can imagine this scenario:

  • Then you can redirect the console with sink

     con <- file("pointsselected.log") sink(con, append=TRUE) 
  • Selects some points on the chart.

  • select a point not in the panel (outside the graph)

  • restore console

     sink() 
  • read all selected points

      cat(readLines("pointsselected.log"), sep="\n") 

But using interactive options is still experimental, and details may change in the future.

+1
source

This is very close to what I'm looking for, sent yesterday to the help list R: http://r.789695.n4.nabble.com/Focus-on-a-sub-panel-of-a-splom-with-trellis -focs-return-coordinate-of-sub-panel-or-names-of-variabln-td4652825.html

1) Build the same splom() as above.

2) Make sure you run library(grid)

3) Now run the following lines:

 trellis.focus() names(iris)[round(unlist(grid.locator()))] 

4) Click on any part of the graph, and then end the focus session:

 trellis.unfocus() 

I say this is very close because it does exactly what I want, but I want the names(.)[.] Capture to remain open even after clicking. Any thoughts?

0
source

All Articles