Skip to content

Commit

Permalink
new package
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhanigan committed Nov 30, 2012
1 parent 06e19b1 commit 369ef34
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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 <yourfault@somewhere.net>
Description: More about what it does (maybe more than one line)
License: What license is it under?
1 change: 1 addition & 0 deletions NAMESPACE
@@ -0,0 +1 @@
exportPattern("^[[:alpha:]]+")
51 changes: 51 additions & 0 deletions 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)
}
40 changes: 40 additions & 0 deletions 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 <yourfault@somewhere.net>
~~ 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[<pkg>:<pkg>-package]{<pkg>}} ~~
}
\examples{
~~ simple examples of the most important functions ~~
}
128 changes: 128 additions & 0 deletions 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

0 comments on commit 369ef34

Please sign in to comment.