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

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.

Related

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

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.

What are the different ways to update an Excel sheet from R

I am in the process of automating a number of graphs that are produced where I work through R that are currently in Excel.
Note that for now, I am not able to convince that doing the graphs directly in R is the best solution, so the solution cannot be "use ggplot2", although I will push for it.
So in the meantime, my path is to download, update and tidy data in R, then export it to an existing Excel file where the graph is already constructed.
The way I have been trying to do that is through openxlsx, which seems to be the most frequent recommendation (for instance here).
However, I am encountering an issue taht I cannot solve with this way (I asked a question there that did not inspire a lot of answers !).
Therefore, I am going to try other ways, but I seem to mainly be directed to the aforementioned solution. What are the existing alternatives ?

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.

How to disable package without restarting R? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to unload a package without restarting R?
To load a package into R we can go library(.) or require(.). How do I disable a package during a coding session. I want something that's the opposite of require(.).
I think maybe you're looking for detach(package:splines, unload = TRUE).
As you might gather from the comments below, be sure to read carefully the Details section of ?detach to make sure you know exactly what will happen when using this with or without the unload and force arguments.

Resources