Setting up R in Atom: How to Run a Help Page - r

I successfully set up R in my new Atom editor and can get in-line results using the Hydrogen package. I just noticed, however, that when I run lines to obtain "R Documentation" that would pop up automatically in RStudio, Hydrogen only gives me a check mark in-line result with no associated documentation.
Here is what is going on in my Atom editor when I run ?plot
Here is what happens in RStudio (bottom right pane), which I am hoping I can get in Atom
How can I get this working in Atom?

try hydrogen -> Toggle inspector

I had the same question and actually made a little progress. Perhaps someone more experienced than I can use this to make a package to enable an in-atom help documentation panel for us :)
Anyway you can install the atom package 'script' which will properly output some, but not all, help documents. I have an example of one working & one not working.
Working ?read.csv
Not-working ?geom_bar

Related

How to refresh plots without needing to close the previous plot?

How do I get VSCode to refresh the plot when making a new plot without needing to close the previous plot tab?
Ideally, it should open up a new tab with the new plot next to the old one.
Moreover, when using Httpgd, even tho the plot refreshes without me having to close the previous plot, it opens up in a separate window outside VSCode. How do I get it to open up as a new tab like in the gif above?
I had the exact same problem and what fixed it for me was simply, in vscode, going into:
Files > Preferences > Settings > section Extensions > scroll down and find R:
find the section "Plot: Use Httpgd" and check it, and restart Vscode.
I can't confirm but I believe it might have started after installing the httpgd package, because I had the behavior you desire before installation, and the exact same behavior you experience after httpgd installation. Of course if my solution works for you (I hope), it will work under httpgd after and not the base default VsCode/R-plot viewer as in your gif.
#coip pointed out that the steps given on this stackoverflow post to me. Downloading the httpgd package from CRAN fixed the problem for me.

Atom and Hydrogen: Output and console

I'm a Python beginner and recently came across the Atom editor and the package Hydrogen, that implements the Jupyter notebook. I did so after realizing that running the notebook in Chrome consumed way too many resources and also seemed to be a bit slower.
However, the Atom editor and Hydrogen always output prints within a little frame in the code (see image). Unfortunately, it doesn't use the full window width. I also don't see any console/terminal for installing pip libraries.
Is there a way to have the output in a console below the code, just as in Jupyter, and to have a terminal?
this comes most certainly too late, but in case someone else searches for this:
hit control+shift+P / cmd+shift+P and type "toggle output area".

r plot shows up only when I type in console but not in script

I ran into a very weird problem: my R code for generating a plot only works if I type it into the console but not when I ran it inside the script (with Ctrl+Enter command)... It's the same problem with all plots (regular plots or ggplots). Also I tried it on two different computers and the same thing happened. Anyone have any idea why this is happening?
One possible reason: I installed the newest version of Rstudio on both computers so it might be an issue with the version. The exact same code worked before on an older version of rstudio...Could this be it? If so, how can I fix it?
I think I figured out what the problem was: the setting in the new version of Rstudio has a default option of outputting the plots inside the Rmarkdown script (at the very end of the script). And that's why I wasn't seeing them. You could change the setting such that it outputs in the console.
Try dev.off() to reset the graphics device.
This helps with a lot of weird graphics behaviour.
Probably too late for the original poster... However, I just ran into the same problem after installing an R update. The way I fixed it was to go to preferences, R markdown, and turn off "show inline output". For me, it was just coming out at the bottom of the chunk instead of in the plot window like I wanted. Hope that helps someone!
I just ran into this problem. I mistakenly put my plot() command inside the r markdown setup chunk. I moved it to its own code chunk and it ran as expected.

Installing / Using R Packages in Sublime Text 3

I am trying to use the R function dmvnorm (found in the mvtnorm package) in Sublime Text 3. I installed it and ran my code in RStudio, so I know the code is fine. In sublime, I entered:
install.packages('mvtnorm',repos='http://cran.us.r-project.org')
library(mvtnorm)
It looked as though it worked, but when I ran my code it said:
Error: could not find function "dmvnorm"
I'm using a Mac and my hunch is this is somehow related to specifying the path in Preferences -> Package Settings -> Sublime REPL -> Settings - User. The current path displayed as part of the error reads:
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Thanks!
I had a hard time with this recently as well. I'm very new to R so I'm not sure this is the best answer, but to hold you off until someone gives a better one, did you include library('package.name') in the file (in sublime)? require('package.name') also works, but this appears not to be best practice for reasons described, e.g., here.
I hope this helps!

How to see man page of a function of a user installed R library/package?

I have installed a library that contains lot of functions. I want to see calculations done in those functions. How to reach man page of these function in R prompt ?
I only know library(help="name of library") command to seek help.
The shortcut is:
?command
The longer version, for commands such as if for which the shortcut won't work, is:
help("command")
If you need to find a command in installed packages:
help.search("command")
If you need to find a command in all possible packages, the sos library is the ticket.
If you were using the ggplot2 package, go to google, type in something like :
'r ggplot2'
In the results look for the sites that look like this:
cran.r-project.org/package=ggplot2
and start with 'cran.r-project.org/....'
Click on that link and you will see a page for the package. You want to click on either the Reference Manual or for some packages there are Vignettes with more involved explanations and examples. However, the Reference Manual is usually pretty good for examples of how to use the package functions.

Resources