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.
Related
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.
This question already has answers here:
R: What do you call the :: and ::: operators and how do they differ?
(1 answer)
What are the double colons (::) in R?
(2 answers)
Closed 3 years ago.
I am new to R, when reading functions documentation how do I interpret ::?
How do I actually read the syntax?
readxl::read_excel()
Not sure if in R studio I can find any information about
In R there are different packages available,
"readxl" is one of them.
When you install a package, you are ready to use its functionalities.
If you just need a sporadic use of a few functions or data inside the
package you can access them with the notation packagename::functionname().
For example, since you have installed the readxl package, you can explore one of its functionality called read_excel() to import/read excel sheet.
Command to check what functions and data are contained in a package.
help(package = "packageName")
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
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.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
View the source of an R package
I want to see the source code of stats::reorder.
This answer seems not apply to built in packages which are compiled to bytecode:
> stats::reorder
function (x, ...)
UseMethod("reorder")
>bytecode: 0x103321718<
>environment: namespace:stats<
This has nothing to do with reorder being compiled to bytecode and everything to do with it being a generic function.
My answer here elaborates on this.
But specifically for this situation if you want to see the code you can use
# Find what methods are available for reorder
methods(reorder)
# Attempt to check out the code for reorder.default
reorder.default
# Use getAnywhere to view code regardless of if it is exported
getAnywhere(reorder.default)
As others have said, you want methods(reorder). But for your mode general question, the best way is to download the source code of R, and search the code with grep. You can also browse the code online but it's not always obvious in which file a particular function might live.
This isn't a matter of compilation, what you're seeing is the result of the fact that reorder is written to do different things depending on the class of what you want to reorder. There are separate reorder functions for different possible options, and you can list them by calling methods(reorder). You can then examine the source of whichever one is appropriate.