# TODO: Add comment
#
# Author: ecor
###############################################################################
#### color.bar
NULL
#'
#' Creates an 'geotop.inpts' files the keyword and their values of a date.frame like the one returned by \code{\link{declared.geotop.inpts.keywords}}
#'
#'
#'
#' @param df data frame returend by \code{\link{declared.geotop.inpts.keywords}}
#' @param file connetion or file name where to write 'df'
#' @param wpath complere path to \code{file} (optional). Default is \code{NULL}.
#' @param comment.lines string or vector of strings to add as comments for each keyword. If it is \code{NULL} the comment lines are omitted.
#' @param header string or vector of strings to add as a header. If it is \code{NULL} the header is omitted.
#' @param ... further arguments for \code{\link{writeLines}}
#'
#'
### @details The arguments \code{comment.lines} and \code{header} are set equal to \code{"default"} if not indicated (see the function usage).
### In this case they will be replaced by the character string: \n
### \n
### \code{paste("!",c(""," insert optional comment for the keyword below",""),sep="")} for \code{comment.lines}
### and
### c("",paste("!",file,"automatically generated by create.geotop.inpts.keyword (\'geotobricks\' CRAN R Paackage)"),"","")
### for \code{header}
#'
#' @details In case \code{comment.lines} and \code{header} are set equal to \code{"default"},
#' they are suitably modified within the function code.
#' See the example output.
#'
#'
#' @export
#'
#' @examples
#'
#' library(geotopbricks)
#' \dontrun{
#' #Simulation working path
#' wpath <-
#' 'https://raw.githubusercontent.com/ecor/geotopbricks_doc/master/simulations/panola13_run2xC_test3'
#' ## URL path (RAW VERSION) of
#' ## https://github.com/ecor/geotopbricks_doc/tree/master/simulations/panola13_run2xC_test3
#' df <- declared.geotop.inpts.keywords(wpath=wpath)
#' create.geotop.inpts.keyword(df=df)
#' }
#'
#'
#' @seealso \code{\link{writeLines}},\code{\link{declared.geotop.inpts.keywords}}
#'
#'
create.geotop.inpts.keyword <- function(df,file='geotop.inpts.copy',wpath=NULL,
comment.lines="default",
header="default",...) {
if (comment.lines=="default") comment.lines <- paste("!",c(""," insert optional comment for the keyword below",""),sep="")
if (header=="default") heeader <- c("",paste("!",file,"automatically generated by create.geotop.inpts.keyword (\'geotobricks\' CRAN R Paackage)"),"","")
condition_wpath <- (!is.null(wpath) & !is.na(wpath) & wpath!=FALSE)
if (length(condition_wpath)==0) condition_wpath=FALSE
if (condition_wpath) file <- paste(wpath,file,sep="/")
df <- df[df$Keyword!="",]
lines <- paste(df$Keyword,"=",df$Value)
if (!is.null(comment.lines)) {
NLINES <- (length(comment.lines)+1)*length(lines)
lines_temp <- lines
lines <- rep(c(comment.lines,"KEYWORD"),length(lines_temp))
lines[lines=="KEYWORD"] <- lines_temp
}
if (!is.null(header)) lines <- c(header,lines)
base::writeLines(lines,con=file,sep="\n",...)
return(0)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.