Is there a better way to create a GUI in R? [duplicate] - r

This question already has answers here:
How to create a GUI via R?
(1 answer)
GUI frontend for R script
(3 answers)
Closed 7 months ago.
I am working on a program to analyze and process data for my lab, and I want to make it easier to use for others in my lab who are not as familiar with programming or the R workspace as I am.
Of course the first thing that comes to mind is a GUI, but all the answers and suggestions I have seen are around a decade old at this point and some packages like gWidgets2 do not quite work the same as their predecessors and the newer versions are severly lacking in accessable tutorials for someone like me who only has a mild ammount of experience in R, and no experience designing/working with GUIs.
I already have most of the actual programming done. I just need a GUI element that takes an integer input, and another element that takes a list of strings. Then I need both of those passed to R where it can complete its data arrangement according to what I have already written.

Related

How to run R script without opening R or RStudio? [duplicate]

This question already has answers here:
Run R script from command line
(7 answers)
Closed 2 years ago.
thanks for your time.
I have a more general question, related to a business use case.
I created an R script that takes an excel file, checks certain conditions, and then exports out another excel file.
I created this for a specific use case, and for other people in my organization on a certain team.
The other people in my organization would like to be able to run this R script on their own, without having to contact me every time they want to run it. They could be running it upwards of a few times a day across the entire team.
On my end, I do not want the team members to have to open up R each time they want to run the script. It doesn't seem very user friendly from their perspective, and I would prefer to keep the experience easy for them.
So here's my question: Is there any application I can find or create that the team members can use to run my R script, without having to use R explicitly?
I've done quite a bit of googling around. One solution I saw was to create an executable version of the file, but I believe that would still be tricky since that would involve customizing each of the team members computers.
I also thought that RShiny might be able to fill the gap? But I am not familiar with RShiny as of now, and do not know what exactly it can do.
Thanks for any other suggestions you may have.
There are mainly two ways. with using Rscript, like below:
C:\Users\automat7> Rscript app.r
or in some cases, like with shiny or when running a one line script, usually, you can use
R -e "shiny::runApp(address_to_folder, args)"
You may need to add the R's bin folder to your PATH environment variable if you are using Windows.
You can follow the instructions here for that: How to Add a folder to Path environment variable in Windows10

R - Encrypt / Lock Down R Code and Package [duplicate]

This question already has answers here:
Protect/encrypt R package code for distribution [closed]
(2 answers)
Closed 5 years ago.
Is it possible to create an R package such that if I give it to a user, they could run all the functions within the package, but not be able to view any of the source code?
The two possible ways I can think of would be someone opening up the raw .R files within the package, or by typing the function name in the R console to print the R code text. So is there a way to encrypt the files or disable the function print calls for the functions?
Thanks
Luckily, there is no such functionality. If you want to hide your analysis or algorithm, perhaps you could use some proprietary software or write your code in a language which compiles (e.g. C++). Note that all software is reverse-engineerable. It's just a matter of motivation.

R - how to "save" the loaded packages [duplicate]

This question already has answers here:
How to load packages in R automatically?
(4 answers)
Closed 5 years ago.
Recently moved over to R (from MATLAB) - enjoying it…
…However, every time I close R down, I lose all the packages which I loaded in my previous session, and I need to load them up again (I use a Mac OS).
I know there is a way to save the current loaded packages, and have them load up automatically each time I reopen R - I have seen the answer in a few places, but I don't understand the terminology.
Can someone kindly walk me through it… Click by click?
With appreciation
I do it with my .Rprofile file which resides in my default working directory. (I also un-hide my dot-files so it's easy to get at it.) I use Sys.setenv() to maintain the needed PATH environment variable and then load my packages with:
require(lattice)
require(sos)
require(rms)
Demonstrations of how to edit text-files and control of system resources are not really on-topic in SO. You should be able to teach yourself those skills by searching,
It's kind of amusing that one of the most highly voted R questions is closed as not constructive: Expert R users, what's in your .Rprofile? I will admit that technically it probably does violate the stated rules, but you may find it useful, both for the information and to see what sort of question is considered "on- (or off-)topic" in SO.

List of functions of a package [duplicate]

This question already has answers here:
Show names of everything in a package
(4 answers)
Closed 5 years ago.
Is there an easy, friendly way to list all functions of a package without downloading those huge PDFs (package references)? I need this for getting me familiar with the package, finding proper functions etc.
I tried ?rjags but it doesn't do what I expected.
Load the package (for example the carpackage). Then use ls()
ls("package:car")
The closest thing I've been able to find for this is:
help(,"rjags")
The first parameter specifies the searched thing, second one specifies the package. By keeping only the second one, I hope to get all help pages that relate to that package. This is equivalent of
help(package = "rjags")
This might not work in general though, as in ?help the functionality of omitting the first parameter is described as
topic is not optional: if it is omitted R will give
If a package is specified, (text or, in interactive use only, HTML) information on the package, including hints/links to suitable help
topics.

Self-documenting codes in R? [duplicate]

This question already has an answer here:
Automatic documentation of datasets
(1 answer)
Closed 8 years ago.
Is there any code self-documenting system for R?
I think writing documentation is a very important part of any statistical analysis. There are always important details in your code or the steps of data cleaning that are not reflected in the final analysis report. I wonder whether there is any efficient self-documenting system (or approach) in R that can help me documenting my codes including my comments o my codes with structure files explaining the structure of the datasets (or tables) used in my code?
Beyond using Sweave or knitr in R, is there any other way of doing that?
I'd suggest bundling up your code and data sets in an R package. There's a steep learning curve the first time you do it, but if you're at the point where you're asking, "how can I better manage this code documentation thing", you're likely ready to take the plunge.
Plus, doesn't the idea of typing ?myOwnFunction or ?myOwnDataset, and having the appropriate help file pop up (just as it does when you do ?mean or ?iris) sound appealing?
You might try writing your code as a Sweave or kntr file, which contains LaTeX text along with R code. This process produces a pdf of your text, including your code, and executes your code.
If you choose to organise your analysis as package, you can use roxygen2 for documentation of your code and data.

Resources