R/restore_addins.R

Defines functions restore_addins

Documented in restore_addins

#' @title Restore package addins
#' @description Restores addins.dcf files of installed package
#' @param package character, packages to restore default addins, if NULL all packages will
#' be restored, Default: NULL
#' @rdname restore_addins
#' @export
restore_addins <- function(package=NULL){

  current_keys <- fetch_addins(fields = c('Package','libpath'))

  restore_pkg <- current_keys[match(unique(current_keys$Package),current_keys$Package),]

  if(!is.null(package))
    restore_pkg <- restore_pkg[restore_pkg$Key%in%package,]

  sapply(restore_pkg$libpath,function(x){
    file.copy(x,gsub('_addins.dcf$','addins.dcf',x),overwrite = TRUE)
  })

  return(invisible(NULL))

}

Try the rsam package in your browser

Any scripts or data that you put into this service are public.

rsam documentation built on Jan. 8, 2018, 5:04 p.m.