Title: | Enhanced Wrapper to Show Which Functions Call What |
---|---|
Description: | Enhances the functionality of the mvbutils::foodweb() program. The matrix-format output of the original program contains identical row names and column names, each name representing a retrieved function. This format is enhanced by using the find_funs() program [see Sebastian (2017) <https://sebastiansauer.github.io/finds_funs/>] to concatenate the package name to the function name. Each package is assigned a unique color, that is used to color code the text naming the packages and the functions. This color coding is extended to the entries of value "1" within the matrix, indicating the pattern of ancestor and descendent functions. |
Authors: | Barry Zeeberg [aut, cre] |
Maintainer: | Barry Zeeberg <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.0 |
Built: | 2025-02-13 03:58:21 UTC |
Source: | https://github.com/cran/foodwebWrapper |
insert tags into HTML code to implement rotating table text
addStyle(x, m, colorMap, pawn)
addStyle(x, m, colorMap, pawn)
x |
character vector containing HTML code |
m |
character matrix containing table that is represented in x |
colorMap |
character array of colors |
pawn |
Boolean if TRUE use chess symbols rather than rectangles in html table |
returns modified HTML code
if(interactive()){ load("data/x_x2.RData") load("data/x_m5.RData") load("data/x_colorMap.RData") y<-addStyle(x_x2,x_m5,x_colorMap,pawn=TRUE) }
if(interactive()){ load("data/x_x2.RData") load("data/x_m5.RData") load("data/x_colorMap.RData") y<-addStyle(x_x2,x_m5,x_colorMap,pawn=TRUE) }
print a list of attached packages and their functions for the user to select from
attachedFunctions(verbose)
attachedFunctions(verbose)
verbose |
Boolean if TRUE output several user messages |
returns a list whose components are
l list of user-selected packages and corresponding functions
where character vector of selected packages
if(interactive()){ attachedFunctions(verbose=TRUE) }
if(interactive()){ attachedFunctions(verbose=TRUE) }
same as attachedFunctions() but no user interaction needed
attachedFunctionsBatch(packs)
attachedFunctionsBatch(packs)
packs |
list of character strings containing the names of packages package name is like "pack", not like "package:pack" |
returns a list whose components are
l list of user-selected packages and corresponding functions
where character vector of selected packages
if(interactive()){ attachedFunctionsBatch(c("SherlockHolmes","textBoxPlacement")) }
if(interactive()){ attachedFunctionsBatch(c("SherlockHolmes","textBoxPlacement")) }
print a list of attached packages for the user to select from
attachedPackages()
attachedPackages()
returns a character vector of selected packages
if(interactive()){ attachedPackages() }
if(interactive()){ attachedPackages() }
add tag to color function name in column 2, based on package in column 1
colorTag(v1, v2, nc, x, colorMap, pawn)
colorTag(v1, v2, nc, x, colorMap, pawn)
v1 |
character vector first column of m (excluding first 2 entries of m) |
v2 |
character vector second column of m (excluding first 2 entries of m) |
nc |
integer number of columns of m |
x |
return value of replaceRotTag() |
colorMap |
character array of colors |
pawn |
Boolean if TRUE use chess symbols rather than rectangles in html table |
v1 is first column of m (excluding first 2 entries of m) v2 is second column of m (excluding first 2 entries of m)
returns
match the package names with the function names
concatPackFunc2(m, v)
concatPackFunc2(m, v)
m |
character matrix return value component $funmat of foodweb() |
v |
character vector of package names returned by find_funz() |
returns augmented character matrix m
if(interactive()){ load("data/x_x.RData") load("data/x_v.RData") m<-concatPackFunc2(x_x$funmat,x_v) }
if(interactive()){ load("data/x_x.RData") load("data/x_v.RData") m<-concatPackFunc2(x_x$funmat,x_v) }
create a permutation list of package names for re-ordering rows and columns of matrix m, in decreasing order of function counts per package
consolidate(v)
consolidate(v)
v |
character vector of package names component of return value of find_funz() |
returns a list whose components are character vector for permuting order of m
if(interactive()){ load("data/x_v.RData") l<-consolidate(x_v) }
if(interactive()){ load("data/x_v.RData") l<-consolidate(x_v) }
determine in which R package a function ‘resides’
find_funz(packs, rfuns)
find_funz(packs, rfuns)
packs |
list of character strings containing the names of the packages |
rfuns |
list of character strings containing the names of functions in packs to which the result is to be restricted |
returns vector of character strings, names are functions and values are packages
if(interactive()){ load("data/x_packages.RData") load("data/x_funs.RData") find_funz(packs=x_packages,rfuns=x_funs) }
if(interactive()){ load("data/x_packages.RData") load("data/x_funs.RData") find_funz(packs=x_packages,rfuns=x_funs) }
wrapper for the function foodweb() concatenate the R package name for each retrieved R function
foodwebWrapper( where = character(0), ofile = "~/foodwebWrapper.html", zeros = TRUE, pawn = FALSE, verbose = TRUE )
foodwebWrapper( where = character(0), ofile = "~/foodwebWrapper.html", zeros = TRUE, pawn = FALSE, verbose = TRUE )
where |
position(s) on search path, or an environment, or a list of environments |
ofile |
character string containing path name for output file |
zeros |
Boolean if TRUE delete rows and cols that contain all 0's |
pawn |
Boolean if TRUE use chess symbols rather than rectangles in html table |
verbose |
Boolean if TRUE output several user messages |
if where is missing, then the user is presented with the option of choosing from a list of attached packages
foodweb returns an object of (S3) class foodweb. This has three components:
funmat a matrix of 0s and 1s showing what (row) calls what (column). The dimnames are the function names.
x shows the x-axis location of the centre of each function's name in the display, in par("usr") units
level shows the y-axis location of the centre of each function's name in the display, in par("usr") units. For small numbers of functions, this will be an integer; for larger numbers, there will some adjustment around the nearest integer
if(interactive()){ load("data/x_packages.RData") ofile<-sprintf("%s/foodwebWrapper.html",tempdir()) foodwebWrapper(ofile=ofile) foodwebWrapper(where=x_packages,ofile=ofile) }
if(interactive()){ load("data/x_packages.RData") ofile<-sprintf("%s/foodwebWrapper.html",tempdir()) foodwebWrapper(ofile=ofile) foodwebWrapper(where=x_packages,ofile=ofile) }
foodwebWrapper data sets
data(funs_examples)
data(funs_examples)
map functions to color coding
mapFunctionsColors(row1, col1, colors)
mapFunctionsColors(row1, col1, colors)
row1 |
character vector containing names of packages |
col1 |
character vector containing names of packages |
colors |
character vector containing names of colors |
returns a character vector mapping colors to package names
if(interactive()){ colors<-c("darkmagenta","darkolivegreen","darkorange3","brown4","red","blue") load("data/x_m3.RData") colorMap<-mapFunctionsColors(x_m3[1,c(-1,-2)],x_m3[c(-1,-2),1],colors) }
if(interactive()){ colors<-c("darkmagenta","darkolivegreen","darkorange3","brown4","red","blue") load("data/x_m3.RData") colorMap<-mapFunctionsColors(x_m3[1,c(-1,-2)],x_m3[c(-1,-2),1],colors) }
rearrange the order of rows or columns of matrix based on entries in a vector
rearrangeM(m, v2)
rearrangeM(m, v2)
m |
character matrix return value of concatPackFunc2() |
v2 |
list whose components are package names for permuting order of m, return value of consolidate() |
returns rearranged version of m
if(interactive()){ load("data/x_m.RData") load("data/x_v2.RData") m2<-rearrangeM(x_m,x_v2) }
if(interactive()){ load("data/x_m.RData") load("data/x_v2.RData") m2<-rearrangeM(x_m,x_v2) }
delete rows and cols of matrix m that contain all "0"s
removeZeroRowsCols(m)
removeZeroRowsCols(m)
m |
character matrix whose entries are either "0" or "1" |
returns an altered version of character matrix m with removed rows and columns
if(interactive()){ load("data/x_m2.RData") m3<-removeZeroRowsCols(x_m2) }
if(interactive()){ load("data/x_m2.RData") m3<-removeZeroRowsCols(x_m2) }
insert html tags for rotating text
replaceRotTag(x, l, dims)
replaceRotTag(x, l, dims)
x |
return value of readLines(), HTML code containing data table |
l |
return values of spanTag() |
dims |
return value of dim() |
returns modified version of HTML code containing data table
if(interactive()){ load("data/x_x.RData") load("data/x_l.RData") load("data/x_m3.RData") x<-replaceRotTag(x_x,x_l,dim(x_m3)) }
if(interactive()){ load("data/x_x.RData") load("data/x_l.RData") load("data/x_m3.RData") x<-replaceRotTag(x_x,x_l,dim(x_m3)) }
add html style definition for rotation
rotStyle()
rotStyle()
returns character string containing html style definition for rotation
r<-rotStyle()
r<-rotStyle()
add html tag to rotate function name
rotTag(v1, v2, colorMap)
rotTag(v1, v2, colorMap)
v1 |
character vector containing first row of matrix m (excluding first 2 entries of m) |
v2 |
character vector containing second row of matrix m (excluding first 2 entries of m) |
colorMap |
character array of colors |
see https://stackoverflow.com/questions/47261100/how-to-rotate-text-90-degrees-inline also need to increase height of row to accommodate rotated text see https://resultuniversity.com/html/html-table-width-height#:~:text=To%20set%20the%20height%20of%20a%20specific%20row%20in%20an,property%20in%20pixels%20or%20percentages.
returns character vector containing inserted html tags
if(interactive()){ load("data/x_m5.RData") load("data/x_colorMap.RData") rt<-rotTag(x_m5[1,c(-1,-2)],x_m5[2,c(-1,-2)],x_colorMap) }
if(interactive()){ load("data/x_m5.RData") load("data/x_colorMap.RData") rt<-rotTag(x_m5[1,c(-1,-2)],x_m5[2,c(-1,-2)],x_colorMap) }
Add html tag for package name to span multiple columns. Also insert hyperlink to CRAN package and function documentation.
spanTag(v, direction = "COLSPAN", colorMap)
spanTag(v, direction = "COLSPAN", colorMap)
v |
character vector representing first row of m (excluding first 2 entries of m) |
direction |
character string COLSPAN or ROWSPAN |
colorMap |
character array of colors |
see https://www.pierobon.org/html/span.htm#:~:text=Cells%20within%20HTML%20tables%20can,span%20more%20than%20one%20column.
returns a list whose components are
u return value of unique(v)
tab return value of table(v)
v2 character vector modified version of v containing html span tags
if(interactive()){ load("data/x_m5.RData") load("data/x_colorMap.RData") l<-spanTag(x_m5[1,c(-1,-2)],"COLSPAN",x_colorMap) }
if(interactive()){ load("data/x_m5.RData") load("data/x_colorMap.RData") l<-spanTag(x_m5[1,c(-1,-2)],"COLSPAN",x_colorMap) }
foodwebWrapper data sets
data(x_colorMap)
data(x_colorMap)
foodwebWrapper data sets
data(x_examples)
data(x_examples)
foodwebWrapper data sets
data(x_packages)
data(x_packages)