DanielBarker
Posts: 72
Joined: Tue May 29, 2012 7:53 am

R statistics software bug on Raspberry Pi

Thu Oct 09, 2014 11:42 am

In the statistics package R, X11 graphics used to work. But with the latest Raspbian and R, they certainly no longer work.

To reproduce:

sudo apt-get install r-base
R
demo('graphics')

Click the graphics window and press RETURN a few times (usually this cycles through the graphics demos). It remains blank.

I am not sure if this is an R problem or a Raspbian problem.

warnings() in R provides some information that might be helpful -

Code: Select all

Warning messages:
1: In dev.flush() :
  X11 protocol error: BadAccess (attempt to access private resource denied)
2: In dev.flush() :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
3: In int_abline(a = a, b = b, h = h, v = v, untf = untf,  ... :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
4: In plot.xy(xy.coords(x, y), type = type, ...) :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
5: In plot.xy(xy.coords(x, y), type = type, ...) :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
6: In title(main = "Simple Use of Color In a Plot", xlab = "Just a Whisper of a Label",  ... :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
7: In plot.new() :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
8: In dev.flush() :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
9: In title(main = "A Sample Color Wheel", cex.main = 1.4,  ... :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
10: In title(xlab = "(Use this as a test of monitor linearity)",  ... :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
11: In plot.new() :
  X11 protocol error: BadShmSeg (invalid shared segment parameter)
Thank you in advance for any advice.

Daniel Barker http://biology.st-andrews.ac.uk/staff/db60

User avatar
DougieLawson
Posts: 37074
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: R statistics software bug on Raspberry Pi

Thu Oct 09, 2014 12:01 pm

I've just tried this on my stock Raspbian system using a VNC session and I got lots of pretty graphs displayed.
I'm pressing [RETURN] in the LXTerminal window where the R command is running.

The only error I saw was

Code: Select all

Error in pairs(iris[1:4], main = "Edgar Anderson's Iris Data", font.main = 4,  :
  object 'iris' not found
Error in pairs(iris[1:4], main = "Edgar Anderson's Iris Data", font.main = 4,  :
  object 'iris' not found
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

DanielBarker
Posts: 72
Joined: Tue May 29, 2012 7:53 am

Re: R statistics software bug on Raspberry Pi

Thu Oct 09, 2014 2:40 pm

Dear DougieLawson,

Thank you very much for your reply - and for making me realise I was simply pressing RETURN in the wrong window!

With RETURN in the LXTerminal, it works fine. The bug, it seems, was human error on my side - not with R or Raspbian.

Thanks again,

Daniel Barker http://biology.st-andrews.ac.uk/staff/db60

DanielBarker
Posts: 72
Joined: Tue May 29, 2012 7:53 am

Re: R statistics software bug on Raspberry Pi [False alarm]

Mon Oct 13, 2014 5:00 pm

Actually, it seems there IS a problem.

If I run R on a Raspberry Pi displayed locally, the demo('graphics') graphics window remains blank white, no matter how many times I press RETURN in the LXTerminal.

If I run R on a Raspberry Pi displayed remotely, i.e. I connect to the Raspberry Pi with ssh -Y from an Ubuntu desktop, the graphics are fine.

So it seems there is something weird going on - works with VNC or remote X11, not local X11.

I am also convinced that this was not a problem previously (e.g. 1-2 years ago).

Does anyone have any thoughts about how to fix this?

Thank you in advance,

Daniel Barker http://biology.st-andrews.ac.uk/staff/db60

User avatar
DougieLawson
Posts: 37074
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: R statistics software bug on Raspberry Pi [False alarm]

Mon Oct 13, 2014 6:07 pm

If you run remotely you need to set your DISPLAY environment variable to the remote display.

DISPLAY=:1 R # should run on a VNC session
DISPLAY=:0 R # runs on the startx X11 windows
R # defaults to DISPLAY=:0 R
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

DanielBarker
Posts: 72
Joined: Tue May 29, 2012 7:53 am

Re: R statistics software bug on Raspberry Pi [False alarm]

Tue Oct 14, 2014 11:11 am

But oddly, it's only the local use of R's graphics that isn't working. Remotely (ssh -Y from Ubuntu) it's fine.

Has anyone else got R graphics working properly, when displayed locally, with the latest Raspbian and R?

If so: clearly the problem would lie somewhere our end.

If not: could it be some weird timing issue, between R and the X11 server? Or: is R expecting some library, used only for local display, which isn't there (or isn't functioning as expected by R)?

Thank you again,

Daniel

shauheen
Posts: 1
Joined: Thu Jan 29, 2015 10:52 pm

Re: R statistics software bug on Raspberry Pi [False alarm]

Thu Jan 29, 2015 10:56 pm

An update on this bug (and it is not false alarm), When you get the empty X11 window, try dev.off(), you will see the graphics for a split second before the X11 device is closed.

lvphj
Posts: 2
Joined: Sun Jul 06, 2014 6:01 pm

Re: R statistics software bug on Raspberry Pi [False alarm]

Sun Jun 07, 2015 9:53 pm

I agree that this is NOT a false alarm. I used to have an installation of R that worked surprisingly well. I installed numerous packages from sources and all was well. However, I managed to completely mess up my original SD card so I had to go back to the drawing board. I created a new SD card with the latest version of Wheezy Raspbian (2015-05-05) and installed R using:

Code: Select all

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install r-base
When I started R and tried to do anything graphical, the graphics window opened but remained blank.

So, I went back to an earlier version of Wheezy Raspbian (namely 2014-06-20) and installed it on an 8GB SD card. I started up the RPi and ran:

Code: Select all

$ sudo apt-get update
$ sudo apt-get install r-base
I then started R and ran the following commands:

Code: Select all

> x=rnorm(1000)
> hist(x)
A graphics window appeared and contained a histogram as expected.

I then quit R and ran:

Code: Select all

$ sudo apt-get upgrade
$ sudo apt-get install --reinstall r-base
Then, when I started R and tried to draw the same histogram as before, the graphics window appeared but it remained empty.

So, my conclusion is that something in the upgrading process introduced since 2014-06-20 is breaking R graphics.

Return to “Troubleshooting”