Learn R Programming

tagcloud (version 0.1)

editor.tagcloud: Simple interactive editing of tag clouds

Description

A minimalistic editor for object of the tagcloud class.

Usage

editor.tagcloud( boxes )

Arguments

Value

An object of the tagcloud class with the modified positions of the tags.

Details

tagcloud provides a minimalistic editor for tag clouds produced by tagcloud function. After edit.tagcloud is called, the tag cloud is plotted. First click selects the tag to be moved. The second click sends the tag such that its left lower corner is at the position indicated by the mouse. Right-clicking terminates the program.

See Also

tagcloud

Examples

Run this code
##---- 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