r - rStudio autocompletion description and usage -
i pretty new in package development r , might stupid question, hope can here...
i develop small package in r using manual hadley wickem http://adv-r.had.co.nz/package-development-cycle.html
i switched dev_mode(), install() package , load library(package name)
so 1 example:
#' logging function #' #' function tries use logging functionality. if logging package #' isn't installed, uses normal print command #' #' @param string string print #' @param level level of log output, example \code{warn}, #' \code{info} or \code{error} #' @examples #' \dontrun{ #' mylog('for information') #' mylog('this warning','warn') #' } mylog <- function(string,level='info') { trycatch( switch(level, warn=logwarn(string), error=logerror(string), info=loginfo(string), {logwarn(sprintf('warnlevel "%s" not defined!',level)) loginfo(string)}), error=function(condition) { cat(sprintf('%s: %s\n',level,string)) }) }
when type ?mylog
in window inside rstudio... when try use auto complete tab, there no information in little popup window...
all other packages have little information there, how use function.
hope can give me hint...
i found solution... or @ least hope so....
adding @export
tag in documentation helps , provides in autocompletion...
#' logging function #' #' function tries use logging functionality. if logging package #' isn't installed, uses normal print command #' #' @param string string print #' @param level level of log output, example \code{warn}, #' \code{info} or \code{error} #' @export #' @examples #' \dontrun{ #' mylog('for information') #' mylog('this warning','warn') #' } mylog <- function(string,level='info') { trycatch( switch(level, warn=logwarn(string), error=logerror(string), info=loginfo(string), {logwarn(sprintf('warnlevel "%s" not defined!',level)) loginfo(string)}), error=function(condition) { cat(sprintf('%s: %s\n',level,string)) }) }
Comments
Post a Comment