Adding gui or easy configurability to package that wraps object with function using shortcut keys

Hello,

I am trying to create a package that cuts down on typing by wrapping a highlighted object in a user-defined one-liner function. For example, you type out mtcars$mpg in the code editor pane, you highlight it, press ctrl+t, and next you will find it wrapped in the table function. Like so, table(mtcars$mpg). This part is complete, but I want to add the following:

  1. Ability for the user to add their own functions. Probably entails a config file being stored in the package, .RProfile, or in "C:\Users\username\AppData\Local\RStudio".
  2. Best case scenario, a shiny app to help the user add/change/remove desired functions that are used frequently.
  3. If possible, allow the user to right click an object in the code editor pane and select a desired function from the context menu to wrap the object. (Probably not probable)

Issues so far:
When I install the package, I notice that all the code becomes "black-boxed"/encrypted, so I am unable to add/change/remove functions when the package is installed in "\R\library\packagename". I even tried leveraging the config package and use the config.yml file, but after installing the package config.yml disappears. The package continues to work from the"\R\library\packagename" path even without config.yml being found anywhere in "\R\library\packagename". I suppose it was baked into the binary of the installed package. Looking at the "options" option so far doesn't look promising.

Addin / Package directory structure:
struc

The "addins.dcf" file contains typical entries for the addin/package
(Only one addins.dcf entry shown)

Name: wrappin-df
Description: wrap text in as.data.frame
Binding: wrappindf
Interactive: false

The wrappr.R file simply references the functions found in the source function.

source( "R/wrappfuncs.txt", local = TRUE  )

The "wrappfuncs.txt" holds the functions. It could be just placed in wrappr.R as well and eliminate this file. (Only one function showed)

wrappinbrack <- function(x){
  context <- rstudioapi::getActiveDocumentContext()
  id <- context$id
  slct <- context$selection
  rstudioapi::insertText(text =  paste("[", slct[[1]]$text ,"]",sep="")  )
}

Would be cool to collaborate if anyone has the time. Otherwise just getting pointed in an advantageous direction would appreciated.

Thanks in advance.

I'll answer my own question.
I placed all files in the inst directory, there I can access and configure them after packaging them.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.