R/nodescloud.R

Defines functions nodescloud

Documented in nodescloud

#$HeadURL: file:///srv/svn/sintro/pkg/sprof/R/nodescloud.R $
#$Id: nodescloud.R 239 2013-09-10 16:12:33Z gsawitzki $
#$Date: 2013-09-10 18:12:33 +0200 (Tue, 10 Sep 2013) $
#$Author: gsawitzki $
#$Revision: 239 $
#\encoding{utf8}
# setwd("")
# source('~/Documents/lectures/src/insider/profile/sprof/pkg/R/nodescloud.R', chdir = TRUE)
#! To Do
#!
nodescloud <- function(sprof, src, min.freq=3, 
	icol, col, ...)
{
if (require(wordcloud)){
	if (inherits(sprof,"sprof")) 
		{	if (missing(src)) src <- sprof$info$id
			nodes <- sprof$nodes 
		} else {
			if (missing(src)) src <- deparse(substitute(sprof))
			nodes <- sprof
		}
	if (missing(icol)) {
		if (is.null(nodes$icol))icol <- rkindex(nodes$self.time, maxindex=16) else
			icol <- nodes$icol
		}
	
	icol <- unclass(icol) # just to make sure...
	
	if (missing(col)) col <- terrain.colors(max(icol))
	
	wordcloud(nodes$name, 
		freq = nodes$total.time,
		min.freq=min.freq, 
		random.order=FALSE,
		rot.per=0.3,
		colors = col[icol],
		ordered.colors=TRUE, ...)
	title(sub=src, col.sub=grey(0.5),font=3)
	} else {
			frame()
			legend("center","package wordcloud \n is required for this plot")
		}
	}

Try the sprof package in your browser

Any scripts or data that you put into this service are public.

sprof documentation built on May 2, 2019, 4:45 p.m.