##---------------------------------------------------------------------------
##
##---------------------------------------------------------------------------
export = function(name, path, comment = NULL, delete = FALSE)
{
fd = file.path(path, "NAMESPACE")
if(file.exists(fd) & delete) file.remove(fd)
if(!file.exists(fd)) writeLines("# Generated by me", fd)
tx1 = readLines(fd)
tx2 = gsub("export\\(|\\)" ,"", tx1)
w = name[!(name %in% tx2)]
## insere commentários
if(!is.null(comment) & length(w))
{
n = length(tx1) + 1
tx1[n] = paste("\n##", comment)
}#end if
writeLines(tx1, con = fd)
## insere nomes das funções
#ni = unlist(sapply(name, grep, tx1))
if(length(w))
{
n = length(tx1)
for(i in 1:length(w))
{
tx1[n+i] = paste0("export(", w[i], ")")
}
}#end if
writeLines(tx1, con = fd)
return(tx1)
}#end function export_ns
##-------------------------------------------------------------
##
##-------------------------------------------------------------
import = function(name, path, comment = NULL, delete = FALSE)
{
fd = file.path(path, "NAMESPACE")
if(file.exists(fd) & delete) file.remove(fd)
if(!file.exists(fd)) writeLines("# Generated by me", fd)
tx1 = readLines(fd)
tx2 = gsub("import\\(|\\)" ,"", tx1)
w = name[!(name %in% tx2)]
## insere commentários
if(!is.null(comment) & length(w))
{
n = length(tx1) + 1
tx1[n] = paste("\n##", comment)
}#end if
writeLines(tx1, con = fd)
## insere nomes das funções
#ni = unlist(sapply(name, grep, tx1))
if(length(w))
{
n = length(tx1)
for(i in 1:length(w))
{
tx1[n+i] = paste0("import(", w[i], ")")
}
}#end if
writeLines(tx1, con = fd)
return(tx1)
}#end function export_ns
##---------------------------------------------------------------------------
##
##---------------------------------------------------------------------------
importfrom = function(pkg, fun, path, comment = NULL, delete = FALSE)
{
fp = paste(pkg, concatena(fun, sep=","), sep=",")
fd = file.path(path, "NAMESPACE")
if(file.exists(fd) & delete) file.remove(fd)
if(!file.exists(fd)) writeLines("# Generated by me", fd)
tx1 = readLines(fd)
tx2 = gsub("importFrom\\(|\\)" ,"", tx1)
w = fp[!(fp %in% tx2)]
if(!is.null(comment) & length(w))
{
n = length(tx1) + 1
tx1[n] = paste("\n##", comment)
}#end if
if(length(w))
{
n = length(tx1) + 1
tx1[n] = paste0("importFrom(", fp, ")")
}#end if
writeLines(tx1, con = fd)
return(tx1)
}#end function importFrom
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.