feedbackr ⤌ R-devs + useRs
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In my last post I explained why I added a feedback function to googleformr. Since googleformr is an API for collecting data programmatically, I figured I’d leverage it for package development and accessibility. Below I’ll show how you can add your own feedback function to your package.
Create your own feedback function
First, make sure to grab googleformr from CRAN, if you haven’t yet. I love pacman as my library / function handler. The p_load
will load a library. If it isn’t installed, it will install from CRAN and then load it.
if (!require("pacman")) install.packages("pacman")
pacman::p_load(googleformr)
You can create your own feedback_pkg_name
function by linking it to a Google Form. Get your forms started at the Google Forms page. Once you have a google form created with one short answer question, grab the form’s url and use code below:
# create function
form <- "your_google_form_url"
feedback_pkg_name <- gformr(form
, custom_reply = "Thanks for supporting pkg_name")
Note: it is recommended to call your feedback function
- something clearly signalling a feedback purpose
- but also something specific to your package.
So a function name following the pattern feedback_pkg_name
should get the best of easy IntelliSense auto-complete and distinguishability from other packages using the same functionality.
Once you re-document and re-build your package and post it to github or CRAN, your users can send feedback directly to you from the R console by simply putting their feedback into your feedback function.
fdbk <- # their comments
feedback_pkg_name(fdbk)
Helper Functionality
You can test that your new feedback_pkg_name
function works by:
- sending a test message to your Google Form and see if it shows up and/or
- using the
check_form_works
function like so:check_form_works( comments_pkg_name("test") )
. Either “All good” will appear or a specific http status message describing the error.
You can also extract Google Form question text or entry points using to make sure you can bring back the same information as is on your form:
# questions
form <- "your_google_form_url"
form %>% get_form() %>% get_form_questions()
# entry ids
form %>% get_form() %>% get_form_entry_ids()
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.