What is the code for hiding install.packages() in R? - r

Currently I'm calling for install.packages() every time I'm loading a library in R, since my laptop seems to always giving me an error message if I don't do that, but I'm kinda sure that I've already installed those packages while setting up RStudio. Is there a way for me to enter those install.packages() on top of every RMD file and then hide them? I've heard that some code could do it. Thanks a lot!

You don't need to install a package each time. Simply run library(whateverpackage) and that's it. You can always suppressMessages(library(whateverpackage)) You can see currently loaded packages using sessionInfo()

Related

do I need to re-install tidyverse all the time?

I am new to R and just wondering if for every dataset I need to work on, I need to re-install tidyverse? I noticed that on the google Data Analytic program, we are always asked to install. Package("tidyverse")
No, you only have to install it once. The program suggests installing it every time to make sure you get it if you don't already have it.
After the first time you install it, it becomes part of your package library, so it is available for scripts to use as long as the package library remains accessible. You can read more about packages and libraries here:
https://hbctraining.github.io/Intro-to-R-flipped/lessons/04_introR_packages.html

Why does R crash when adding DESeq2 as dependency to R package?

I'm writing an R package using devtools and roxygen2. Note that this is my first time making a package, so maybe I am missing something important.
I want to add a dependency, the package, DESeq2. I have tried to do this in a number of ways, but believe the right way is to add the following to my DESCRIPTIONS file.
Depends:
DESeq2
If I add this, when I build and reload I get a fatal error. When running in RStudio it just gives a "Fatal Error" dialog and restarts the application. It appears to build, but when it does, library(myPackage), it crashes immediately.
If I remove the Depends section from the DESCRIPTIONS file it builds and loads fine. What's more, if I include a different package, for example, ggplot2, then it builds and loads fine as well.
What about a package would cause it to fail to load as a dependency and completely crash? Is there another way to require it or is there any way to dig deeper into the cause?
Thanks very much in advance.

change functionality of R package

I am trying to get my head around an R package. I installed it from github, worked with it. Also downloaded the ZIP-File from github which contains the files of the package. For experimental reasons I added some code in the files I downloaded.
Now I would like to see whether my changes do what they are supposed to do.
Is there an easy way to do this?
I would like to avoid creating a whole new package and installing it.
Or is this the only way?
I had the idea to directly change the code in the package I installed (location received from the function path.package()). Unfortunately I cannot access the code there.
The tutorials I read were also not helpful.
I would be thankful for any advice.

tools:RGUI disappears from globalenv R

I just installed the newest version of R for my OS -- R version 3.1.3 for MAC. The tools:RGUI does not load properly. Half the time, I open R and search() does not include tools:RGUI. The other half of the time, it does appear but then quickly disappears from the global environment. As a result, I cannot use the help function or search for and install packages. My internet connection is fine. Any ideas?
I think I figured out the problem; I had detach() at the start of my code. I do not normally attach data as I have been told it is a bad habit that can lead to problems. They were right. I have deleted all the references to attach and detach and things seem to work fine now.

Modifying R packages (snow)

Can anybody give me some direction on editing source code of an R package? From what I've seen, changing the package from within R does not seem to be possible. In editing outside of R, I'm stuck at unpacking the tar.gz. While I can now modify the function to my heart's content, the folder looks nothing like the working snow library. I presume I will need to turn the contents into a tar.gz once again and install it in the standard way?
My colleagues and I have been attempting to get makeSOCKcluster() to work with remote IPs for the past three days. Hangs indefinitely. After digging into the snow package I've found the issue to be in the way newSOCKnode() calls socketConnection(). If I run makeSOCKcluster("IP", manual=T) and then put the output into powershell, it results in the connection being made but the program not completing. However, I can run makeSOCKcluster("IP", manual=T) in one R instance and then run system("output", wait=F, input="") in another instance which results in the program completing. I believe I can simply modify snow to do this automatically.

Resources