Again, a long-standing tcl problem.
In some instances the graph-switch produces an error which seems ignorable.
Here are a variety of results take from the l_help()
NOTE that graph switching on the scagnostics seems to work perfectly.
This is not the case for all the rest.
This email contains all examples. (seven different)
These are all taken from l_help()
on learn:displays:graphs:
NOTE THAT I HAVE FIXED SOME ERRORS IN THE “website”
Please use mine http://rwoldford.github.io/loon/
ZERO: graph switch
Restarting R session...
library(loon)
tt <- tktoplevel()
tktitle(tt) <- paste("Loon graph example with a graph switch")
g <- l_graph.default(parent=tt)
gs <- l_graphswitch(activewidget=g, parent=tt)
tkpack(g, side='left', fill='both', expand=TRUE)
tkpack(gs, side='left', fill='y')
G1 <- completegraph(LETTERS[1:4])
G2 <- loongraph(nodes=c('a','b','c'), from=c('a','a'),
to=c('b','c'), isDirected=FALSE)
G3 <- linegraph(G1)
G4 <- loon::complement(G3)
idG1 <- l_graphswitch_add(gs, G1, label='G1')
idG2 <- l_graphswitch_add(gs, G2, label='G2')
# switch to G2 — Generates TCL popup ERROR
invalid command name "0"
invalid command name "0"
while executing
"0"
("uplevel" body line 1)
invoked from within
"uplevel #0 [$activewidget scaleto world]"
(class "::loon::classes::Graphswitch" method "TreeviewToActivewidget" line 11)
invoked from within
"my TreeviewToActivewidget $id"
(class "::loon::classes::Graphswitch" method "TreeviewSelectEvent" line 5)
invoked from within
"::oo::Obj354::my TreeviewSelectEvent"
(command bound to event)
G3 <- linegraph(G1)
G4 <- loon::complement(G3)
idG1 <- l_graphswitch_add(gs, G1, label='G1')
idG2 <- l_graphswitch_add(gs, G2, label='G2')
# switch to G2
idG3 <- l_graphswitch_add(gs, G3, label='G3=linegraph(G1)')
idG4 <- l_graphswitch_add(gs, G4, label='complement(G4)')
# EVERY SWITCH produces the same ERROR
> l_graphswitch_set(gs, idG3)\
Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") :
[tcl] invalid command name "0”.
TRACEBACK:
4. structure(.External(.C_dotTclObjv, objv), class = "tclObj")
3. .Tcl.objv(.Tcl.args.objv(...))
2. tcl(widget, "set", id) at l_graphswitch.R#265
1. l_graphswitch_set(gs, idG3)
FIRST: l_navgraph
Restarting R session...
library(loon)
ng <- l_navgraph(iris)
# switch to 4d transition graph
TCL error window pops containing the following details:
invalid command name "0"
invalid command name "0"
while executing
"0"
("uplevel" body line 1)
invoked from within
"uplevel #0 [$activewidget scaleto world]"
(class "::loon::classes::Graphswitch" method "TreeviewToActivewidget" line 11)
invoked from within
"my TreeviewToActivewidget $id"
(class "::loon::classes::Graphswitch" method "TreeviewSelectEvent" line 5)
invoked from within
"::oo::Obj354::my TreeviewSelectEvent"
(command bound to event)
SECOND: l_ng_ranges
Restarting R session...
library(loon)
library(scagnostics)
oliveAcids <- olive[,-c(1,2)]
scags <- scagnostics(oliveAcids)
nav <- l_ng_ranges(measures=scags, data=oliveAcids, color=olive$Area)
# switch to Skewed
# no problem
# switch to 4d
# nothing happened
# switch to 3d & 4d
# nothing happens
# THE GRAPHS CHANGE once the slider is moved. NO ERROR
THIRD: l_ng_plots
Restarting R session...
library(loon)
library(scagnostics)
oliveAcids <- olive[,-c(1,2)]
scags <- scagnostics(oliveAcids)
nav <- l_ng_plots(measures=scags, data=oliveAcids, color=olive$Area)
# single node; switching to 4d
# nothing happened (which is correct), switch back to 3d
# nothing happened (again is correct), now select a few plots in the scatteplot matrix
# need to have missing edges.
# switch to 4d
# worked perfectly
# switch to 3d & 4d
# worked perfectly
FOURTH: “Arbitrary measures”
Restarting R session...
library(loon)
set.seed(3212341)
n <- 100
dat <- data.frame(
A = rnorm(n), B = rnorm(n), C = rnorm(n),
D = rnorm(n), E = rnorm(n)
)
m2d <- data.frame(
cor = with(dat, c(cor(A,B), cor(A,C), cor(B,D), cor(D,E), cor(A,E))),
my_measure = c(1, 3, 2, 1, 4),
row.names = c('A:B', 'A:C', 'B:D', 'D:E', 'A:E')
)
nav <- l_ng_ranges(measures=m2d, data=dat, separator=':')
# graph has two nodes A:E and B:D
# no edge between
# select 4d
# nothing happens
# select 3d & 4d
# nothing happens
# switch back to 3d and nothing happens
# Going to drag bottom slider to get a graph
# At -0.047833 we get three nodes B:D, and A:E connected to A:C
# switch to 4d
# seems to have switched but the slider bottom goes back to 0.0092858
# So only two nodes A:E connected to B:D
# switch to 3d
# nothing happens, same graph until we move the lower, then it corrects itself.
FIFTH: “Closures of measures”
Restarting R session...
library(loon)
iqr <- function(x) { diff(quantile(x, probs=c(0.75, 0.25))) }
kurtosis <- function(x) { mean((x-mean(x))^4)/mean((x-mean(x))^2)^2 - 3 }
skewness <- function(x) { mean((x-mean(x))^3)/sd(x)^3 }
s_oliveAcids <- scale(oliveAcids)
m1dc <- measures1d(data=s_oliveAcids, separator='+',
median = median,
irq = iqr,
kurtosis = kurtosis,
skewness = skewness)
nav <- l_ng_ranges(measures=m1dc, color=Area)
Error in l_ng_ranges.default(measures = measures(), data = measures("data"), :
object 'Area' not found
nav <- l_ng_ranges(measures=m1dc)
# which produced the plots.
# single node, move bottom slider to 0.017407
# switch to 4d, slider changes back as before.
SIXTH: 2d scagnostics measures
Restarting R session...
library(loon)
library(scagnostics)
oliveAcids <- olive[,-c(1,2)]
scags2d <- scagnostics2d(oliveAcids)
nav <- l_ng_plots(measures=scags2d, color=olive$Area)
# switching does nothing ... correct only one node.
# select a few plots.
# switching WORKS PERFECTLY AND IMMEDIATELY