R/nodepackage.R

Defines functions nodepackage

Documented in nodepackage

#$HeadURL: file:///srv/svn/sintro/pkg/sprof/R/nodepackage.R $
#$Id: nodepackage.R 185 2013-07-28 17:41:50Z gsawitzki $
#$Date: 2013-07-28 19:41:50 +0200 (Sun, 28 Jul 2013) $
#$Author: gsawitzki $
#$Revision: 185 $
#\encoding{utf8}
# setwd("")
# source('~/Documents/lectures/src/insider/profile/sprof/pkg/R/nodescloud.R', chdir = TRUE)
#! To Do
#!

## cf. source('~/Documents/lectures/src/insider/profile_pkgs/profr_0.2/R/parse.r', chdir = TRUE)
nodepackage<- function(x)
{
nodepackage0 <- function(node)
{where <- getAnywhere(node)$where
	if (length(where)==0) return("<not found>") else{
	where1 <- strsplit(where,':')
	if (is.null(where1)) return("<??>") else
		if (where1[[1]][1] == "package") return(where1[[1]][2]) else
		if (where1[[1]][1] == "namespace") return(where1[[1]][2]) else
		if ((length(where1)>1) && (where1[[2]][1] == "namespace")) return(where1[[2]][2]) else
		{warning(paste(node,"not found. got:",where1)); return("nn")}
		}
}
x <- as.character(x)
xpackage <- rep("nn",length(x))
for (i in (1:length(x))) xpackage[i]<-nodepackage0(x[[i]])
xpackage
}

Try the sprof package in your browser

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

sprof documentation built on May 31, 2017, 1:56 a.m.