Setting the title of the R console - r

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.

Related

R graphics displayed separately of the R GUI in Windows

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

Is it possible to get R intellisense or console output in PowerBI?

I've been trying to get started using R in PowerBI. However, the lack of intellisense and the lack of console output is hindering me. As I can't develop the script in RStudio or in Visual Studio with those aids.
EDIT: PowerBI does a nice thing where you can import data into the application and then work with the drag and drop tools to play around with the data, then when you select data fields that you want to add to an R plot, it creates an R stub that pulls those fields into a data.frame which makes things easy. However, that data is "inside" Power BI, I can't do the same thing in R studio because that data context doesn't exist.
What options are there? Am I missing something?
Thanks.
I think that what you are looking for is R tools for VS. It should make intellisense pick up the context and tell you what you can do with each object. Then for the output, can't you print and check the results in the output window in VS?
This also has R interactive window so when you debug you have a window to place code in, and evaluate it in that context. Say you have a method and you want to debug a statement plot(x, exp(x), type="l", col="green"), instead of making a fix at a time and then re-running to check the results, you can just make the fix say plot(x, exp(x), type="l", col="red") and see how that evaluates. This comes in handy when you wanna try a couple of things and check the results, since you can do it in one go, instead of "making one change and running it" x times.
Let me know if this does the job for you.
The only data context you have in R inside Power BI are Tables, which you pass in parameters of the call of R.Execute. Behind the scene, these Tables will be just dropped on disk as csv and then R process will pick them in order to do whatever you want. Actually this is the only relation between R and PowerBI desktop, if we speak about Transformations using R.
You can easily save such a context from PowerBI using R script of just one function save.image(“filename.RData”), and then open it using load("filename.RData") in your target R development environment.
While you should always test out your R code elsewhere first, it is often not enough for debugging purposes.
for general purpose debugging, you can nest your whole script in a block like this:
out <- capture.ouput({...})
Any intermediate value can be captured in this block with a cat:
cat(intermediate_value_i_want_to_test,'\n')
After your script block is done, simply convert your output to a data.frame and each cat method call will be printed in a new row of out.

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.

Message during big file load in R

Is there any ways to print message during big file load or time consuming processing and calculations in R? if it will be with some countdown timer it will be also great.
Thank's for suggestions.
Look at the functions txtProgressBar, winProgressBar (windows only), and tkProgressBar (tcltk package). These can be used to show a progress bar to indicate how far along in a long process you are. Some of them have room for a label that you could use to give a more specific message.
There are a few functions that will use these (the plyr package), otherwise you need to code the updates yourself, but this is pretty simple if you are using a loop or one of the *apply functions.

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.

Resources