R graphics displayed separately of the R GUI in Windows - r

This question might sound superficial, but if you are a Windows user and install R on it, all graphics are displayed inside the R interface, together with the console window.
My question is whether is possible to customize the GUI in order to work with graphics as a separate window, not included in the R environment, so that we can select it from the Windows panel.

You can use the windows() function, which has width and height and many other arguments

Related

Can I use R without R studio?

We are confused on the difference between R and R studio. We do the majority of our work on R studio but we were required to download R as well. Is regular R necessary for R studio to work?
Indeed, R is the real technology you are using. RStudio is an IDE which makes it easier and nicer. Still, it's just working on top of R.
You should be comparing RStudio to a regular text editor. You can use R without RStudio, you might for instance use a text editor plus a terminal window.
As mentioned by #NewUser Rstudio is simply an IDE, and other alternatives do exist. Check the answer to another question here for a long list of alternatives.
Rstudio is however the most popular IDE, and it comes with quite a few benefits. Auto completion of code, the interactive window for html applications, interactive graphics window, easy connection to various databases with automatic connection string complection etc. However some prefer to use alternative IDE's and you could even set up notebook++ to write and execute your code through the terminal.
The most obvious alternative is likely the R IDE. The minimalistic IDE that comes with the installation has some benefits as well, while being restrictive in others. The most obvious benefit is the far lower usage of memory for each window. My thesis supervisor is a hard-lover of the standard IDE, while a friend of mine simply uses it in cases where he needs to View(...) very large data, and for some reasons can't live with a summary output.
That said this question basically has nothing to do with programming, and is technically considered "off-topic" on stackoverflow as it is asking for recommendations. Other websites in the SO family are simply better for these type of questions.
R studio can be considered as a "skin" over base R, which makes it more user friendly. However, base R can certainly be used without R studio.
The main difference you will experience at a beginner level is that you will need to use functions such as View(), rather than cntrl clicking a dataframe etc.

Line by line analysis and plotting on multiple monitors during presentation

I am preparing a presentation on data analysis and I am provided with a 2-3 monitor and projector head-up. I would like to use one monitor(+projector) for code, one monitor(+projector) for console display and one monitor(+projector) for plots. Monitors are for me, projectors for the audience.
I would also like to run the code line-by-line (similar to the Ctr-Enter feature of RStudio); copy pasting code won't work. I want to use interactive graphics, analysis and plotting on-the-fly so any pre-done analysis won't work.
Is there any way to achieve this? Although Rstudio is a fantastic tool, a rather basic (and one might say easy) feature like panel detachment is not being developed although frequently requested. This would be probably the best solution to what I want.
UPDATE: Any OS (Win, Mac, Linux) will do.
You should be able to use the vanilla R GUI. Within that you have separate panels/windows for code, console, and plots (with as many plot windows as you want by calling a new device like quartz()). You can evaluate a line of code from the script using Cmd-Enter(mac) and Cntr-Enter (pc) plus the default settings highlight the line of interest. You could also use emacs in the same way, which I find much more powerful and fun.

Setting the title of the R console

One quick question to which I could not find answer.
I want to know if it is possible to set the title of the R console to something else (using RGui, on Windows).
The main use I'm thinking of is to show some kind of progress information when running a script which takes a long time to complete.
Any suggestions?
In windows you can use the setWindowTitle function, the name that you give it will show up in the top of the window or be the label on the icon when it is minimized.
I have the following line in my .Rprofile:
utils::setWindowTitle(getwd())
So that each instance of R has a label showing which folder/directory it was opened in (I often have several open at a time that I switch between as I work on different projects). This is nice for starting R by double clicking on the .Rdata file and keeping track of which window is which.
But for indicating the progress of a long running process the progress bars are probably the better approach. In windows you can use winProgressBar or on any platform you can use txtProgessBar or tkProgressBar (the tcltk package is needed for the 2nd). The growing bar is a quick visual of the progress and you can also use the label to give a specific iteration, or other information.

Is it possible to resize an interactive R graphics device with R code?

When using R within an interactive windowing system (such as Windows, Ubuntu, MacOSX) the default behaviour for plot(x) is to open an interactive graphics device (with plot.new() under the hood), and draw stuff on it. The device can be interactively moved, resize and closed, and (depending on the platform) presents other GUI-based operations. It can be closed or copied with R code, with dev.off(), dev.copy() and there are other functions in the family.
Can the device be moved or resized using R code?
I realize that this question may have many platform-specific answers, and all and any detail is welcome. I am most interested in the default Windows install options for the latest version of R, but keen to learn more about the differences between OS environments and other options.
If you really wanted to do this, you could use the GTK libraries and the cairoDevice package. Then you can resize things with RGtk2 calls. It isn't the default install, but is cross platform.
library(RGtk2)
library(cairoDevice)
w = gtkWindow()
da <- gtkDrawingArea()
asCairoDevice(da)
w <- gtkWindow(show=FALSE)
w$add(da)
w$show()
hist(rnorm(100))
w$resize(500, 500)
w$move(200,200)
A collection of past attempts with few answers but possibly useful:
https://stat.ethz.ch/pipermail/r-help/2002-October/025840.html : very old question. Gets the usual snark from BDR. Poster claims "I found in mailing list archives article, that describes how to resize X11 graphical window on *nix through *nix command-line interface from R.:)"
this http://finzi.psych.upenn.edu/R/Rhelp01/archive/13765.html may be what he was talking about, which might (?) still work on X11 systems -- haven't tried it
How to change current Plot Window Size (in R) gives a (hacked) Windows-specific solution that involves recording the graphics, closing the window, and opening another one ...
http://r.789695.n4.nabble.com/Resize-Graphics-Window-td2103378.html (no answer)
http://tolstoy.newcastle.edu.au/R/help/05/10/13546.html asks about Quartz, and gets only answers about how to set the size when opening the window initially
Have you look at the excellent packages by Felix Andrews which bring much interactivity to lattice devices:
latticist
playwith
If your question is about the physical size of the window on the screen: I don't think so. That is a window manager task, and you would have to write (very platform dependent, I suspect) code to alter the window once drawn.

Creating interactive pplets from R Output

Currently, I generate results from statistical analyses (e.g., a three-dimensional plot) and then "manually" move it to processing - a graphics programming language) where I can (with some simple coding) export an interactive java applet (e.g., allow the person viewing the plot to move in, out, and around the data points). Can I keep this whole process within R? Specifically, I want to create an applet (doesn't have to be Java but would need to be web embeddable, interactive (so not a movie), and not require the user to work in R or have to download things) that can be passed on.
Thanks.
Not totally clear on your requirements: can you be sure that the user will have R installed (e.g. can you run a script on their desktops to install everything first)? Does it have to run over the web?
The animation package (http://cran.r-project.org/web/packages/animation/) isn't interactive, but it can create moving images.
The iplots package is useful, although it requires R: http://rosuda.org/iPlots/iplots.html
Similarly, rggobi is extremely useful for interactive graphics, but it also requires R. You can read more http://www.jstatsoft.org/v30/b07/paper and http://www.ggobi.org/rggobi/.
A last example is biplotgui: http://r-forge.r-project.org/projects/biplotgui/
I heard that there's a project in development to create Flash output from R, but I can't find anything about it.
Can I keep this whole process within R?
Check out GGobi:
GGobi is an open source visualization program for exploring high-dimensional data. It provides highly dynamic and interactive graphics such as tours, as well as familiar graphics such as the scatterplot, barchart and parallel coordinates plots. Plots are interactive and linked with brushing and identification.

Resources