##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (boxes)
{
plot.tagcloud(boxes, with.box = T)
nstep <- 10
while (1) {
xvec <- as.vector(sapply(1:nrow(boxes), function(x) seq(boxes[x,
"x"], boxes[x, "x"] + boxes[x, "w"], length.out = nstep)))
yvec <- as.vector(sapply(1:nrow(boxes), function(x) seq(boxes[x,
"y"], boxes[x, "y"] + boxes[x, "h"], length.out = nstep)))
catf("Please click on the label you want to move
")
catf("(right-click to finish)
")
i <- identify(xvec, yvec, n = 1, plot = F)
if (length(i) == 0)
break
i <- as.integer(i/nstep) + 1
if (length(i) == 0)
break
catf("Please click on the new position for:
")
catf("%s
", boxes$tags[i])
xy <- locator(1)
debugpr(xy)
boxes[i, "x"] <- xy[1]
boxes[i, "y"] <- xy[2]
plot(boxes, with.box = T)
}
plot(boxes)
return(invisible(boxes))
}Run the code above in your browser using DataLab