From 369ef348cf151eef739a02756ffc947de20d8687 Mon Sep 17 00:00:00 2001 From: Ivan Hanigan Date: Sat, 1 Dec 2012 00:25:40 +1100 Subject: [PATCH] new package --- DESCRIPTION | 9 +++ NAMESPACE | 1 + R/newnode.r | 51 +++++++++++++++ man/disentangle-package.Rd | 40 ++++++++++++ man/newnode.Rd | 128 +++++++++++++++++++++++++++++++++++++ 5 files changed, 229 insertions(+) create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 R/newnode.r create mode 100644 man/disentangle-package.Rd create mode 100644 man/newnode.Rd diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..2e8426b --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,9 @@ +Package: disentangle +Type: Package +Title: What the package does (short line) +Version: 1.0 +Date: 2012-11-30 +Author: Who wrote it +Maintainer: Who to complain to +Description: More about what it does (maybe more than one line) +License: What license is it under? diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..d75f824 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/R/newnode.r b/R/newnode.r new file mode 100644 index 0000000..b434c07 --- /dev/null +++ b/R/newnode.r @@ -0,0 +1,51 @@ +newnode<-function(name, inputs=NA, outputs=NA, graph = 'nodes', newgraph=F, notes=F, code=NA, ttype=NA, plot = T){ + # USAGE + # nodes <- newnode( # adds to a graph called nodes + # name = 'aquire the raw data' # the name of the node being added + # inputs = REQUIRED c('external sources','collected by researcher') # single or multiple inputs to it + # outputs = OPTIONAL c('file server','metadata','cleaning') # single or multiple outputs from it + # append=F # append to existing graph? if False remove old graph of that name and start new + # TODO + # nodes <- addEdge(from='analyse using stats package', + # to='new data in database server',graph=nodes,weights=1) + # INIT + # source('http://bioconductor.org/biocLite.R') + # biocLite("Rgraphviz") + # or may be needed for eg under ubuntu + # biocLite("Rgraphviz", configure.args=c("--with-graphviz=/usr")) + require(Rgraphviz) + # FURTHER INFO + # see the Rgraphviz examples + # example(layoutGraph) + # require(biocGraph) # for imageMap + # TODO change names in following + dsc <- name + i <- inputs + o <- outputs + # if(!exists('nodes')) { + if(newgraph==T) { + nodes <- new("graphNEL", nodes=c(dsc), + edgemode="directed") + # nodes <- addEdge(from=i, to=dsc, graph=nodes, 1) + } else { + if(length(grep(dsc,nodes@nodes)) == 0) nodes <- addNode(node=dsc,object=nodes) + } + if(sum(i %in% nodes@nodes) != length(i)) { + inew <- i[!i %in% nodes@nodes] + nodes <- addNode(node=inew,object=nodes) + } + nodes <- addEdge(i, dsc, nodes, 1) + #} + if(!is.na(o[1])){ + if(sum(o %in% nodes@nodes) != length(o)) { + onew <- o[!o %in% nodes@nodes] + nodes <- addNode(node=onew,object=nodes) + } + nodes <- addEdge(from=dsc, to=o, graph=nodes, 1) + } + if(plot == T){ + try(silent=T,dev.off()) + plot(nodes,attrs=list(node=list(label="foo", fillcolor="grey",shape="ellipse", fixedsize=FALSE), edge=list(color="black"))) + } + return(nodes) +} diff --git a/man/disentangle-package.Rd b/man/disentangle-package.Rd new file mode 100644 index 0000000..21e79c4 --- /dev/null +++ b/man/disentangle-package.Rd @@ -0,0 +1,40 @@ +\name{disentangle-package} +\alias{disentangle-package} +\alias{disentangle} +\docType{package} +\title{disentangle things +What the package does (short line) +~~ package title ~~ +} +\description{ +More about what it does (maybe more than one line) +~~ A concise (1-5 lines) description of the package ~~ +} +\details{ +\tabular{ll}{ +Package: \tab disentangle\cr +Type: \tab Package\cr +Version: \tab 1.0\cr +Date: \tab 2012-11-30\cr +License: \tab What license is it under?\cr +} +~~ An overview of how to use the package, including the most important functions ~~ +} +\author{ +Who wrote it + +Maintainer: Who to complain to +~~ The author and/or maintainer of the package ~~ +} +\references{ +~~ Literature or other references for background information ~~ +} + +\keyword{ package } +\seealso{ +~~ Optional links to other man pages, e.g. ~~ +~~ \code{\link[:-package]{}} ~~ +} +\examples{ +~~ simple examples of the most important functions ~~ +} diff --git a/man/newnode.Rd b/man/newnode.Rd new file mode 100644 index 0000000..af88f02 --- /dev/null +++ b/man/newnode.Rd @@ -0,0 +1,128 @@ +\name{newnode} +\alias{newnode} +%- Also NEED an '\alias' for EACH other topic documented here. +\title{new node +%% ~~function to do ... ~~ +} +\description{adds to a graphviz graph +%% ~~ A concise (1-5 lines) description of what the function does. ~~ +} +\usage{ +newnode(name, inputs = NA, outputs = NA, graph = "nodes", newgraph = F, notes = F, code = NA, ttype = NA, plot = T) +} +%- maybe also 'usage' for other objects documented here. +\arguments{ + \item{name}{ +%% ~~Describe \code{name} here~~ +} + \item{inputs}{ +%% ~~Describe \code{inputs} here~~ +} + \item{outputs}{ +%% ~~Describe \code{outputs} here~~ +} + \item{graph}{ +%% ~~Describe \code{graph} here~~ +} + \item{newgraph}{ +%% ~~Describe \code{newgraph} here~~ +} + \item{notes}{ +%% ~~Describe \code{notes} here~~ +} + \item{code}{ +%% ~~Describe \code{code} here~~ +} + \item{ttype}{ +%% ~~Describe \code{ttype} here~~ +} + \item{plot}{ +%% ~~Describe \code{plot} here~~ +} +} +\details{ +%% ~~ If necessary, more details than the description above ~~ +} +\value{ +%% ~Describe the value returned +%% If it is a LIST, use +%% \item{comp1 }{Description of 'comp1'} +%% \item{comp2 }{Description of 'comp2'} +%% ... +} +\references{ +%% ~put references to the literature/web site here ~ +} +\author{ +%% ~~who you are~~ +} +\note{ +%% ~~further notes~~ +} + +%% ~Make other sections like Warning with \section{Warning }{....} ~ + +\seealso{ +%% ~~objects to See Also as \code{\link{help}}, ~~~ +} +\examples{ +require(disentangle) +nodes <- newnode(name = 'aquire the raw data', + inputs = c('plan', 'external sources', + 'collected by researcher'), + outputs = 'cleaning', + newgraph=T) + +nodes <- newnode(name = 'file server', + inputs = 'cleaning' + ) + +nodes <- newnode(name = 'database server', + inputs = 'file server', + outputs = c('metadata database') + ) + +nodes <- newnode(name = 'search engine web server', + inputs ='metadata database', + outputs = NA + ) + +nodes <- newnode(name = 'calculate new data', + inputs = 'database server', + outputs = + c('analyse using stats package','database server', + 'metadata database', 'technical documentation') + ) + +nodes <- newnode(name = 'analyse using stats package', + inputs = c('database server','simulation', + 'file server', 'cleaning'), + outputs = c('results', 'metadata database', + 'cleaning', 'technical documentation') + ) + +nodes <- newnode(name = 'communicate the results', + inputs ='results', + outputs = c('journal publication') + ) + +nodes <- newnode(name='technical documentation', + inputs = c('aquire the raw data', + 'communicate the results'), + outputs = 'cleaning' + ) + +nodes <- newnode(name = 'archive at end of project', + inputs ='journal publication', + outputs = c('repurposed data','file server', + 'destroy') + ) + +#dev.copy2pdf(file='transformations_overview.pdf') +#dev.off(); + +} +% Add one or more standard keywords, see file 'KEYWORDS' in the +% R documentation directory. +\keyword{ ~kwd1 } +\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line