2

I have many R sessions open. Searched in Rgui Options, not sure how to name each of the sessions that are open and in use.

enter image description here

Searched in GUI Preferences in R, couldn't get any help. Checked on how to do it with commands, it says each session has its own process ID, to find that used Sys.getpid()

Want to select R session based on name of the R session window.

Sowmya S. Manian
  • 3,723
  • 3
  • 18
  • 30
  • Why do you have so many RGuis opened and in use? – Dason Jun 26 '18 at 18:59
  • 1
    If you need to do this kind of thing and are open to working in RStudio, you can create RStudio projects that are named and organise code for a particular thing in a directory. The session is then named after the project. – Calum You Jun 26 '18 at 19:13

1 Answers1

3

My version of Windows is displaying the tray icons differently, but I can tell different GUIs apart by setting the Window name using setWindowTitle. For example,

setWindowTitle("Fred")

I get a display like this.

Tray Icons

If you need this to happen automatically, you could generate a random name and stick this statement in your .Rprofile

setWindowTitle(paste0(sample(LETTERS, 3, replace=TRUE), collapse=""))
G5W
  • 36,531
  • 10
  • 47
  • 80
  • This is so much enough. Tried and works. Thank you. Was curious since a month if it can be done. Searched across `apropos("Sys.")`, `apropos("session")`..couldn't find any help. – Sowmya S. Manian Jun 26 '18 at 19:21
  • I am glad to help. – G5W Jun 26 '18 at 19:23
  • and if you keep increasing the no. of sessions, then it will display the tray icon like I have in mine. When the sessions were less, it was like how you have in screenshot. – Sowmya S. Manian Jun 26 '18 at 19:24