3

I have installed XQuartz on my machine using homebrew and then I restarted my machine, when I try to use the fix() command in RStudio I get the following error

> College=read.csv("College.csv",header=T,na.strings ="?")
> fix(College)
Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) : 
  X11 is not available

When I try to the following in terminal it works as expected. How can I make the same command work in RStudio

cod3min3
  • 585
  • 1
  • 7
  • 23
  • 1
    Did you try uninstalling the Homebrew version and using the actual installer? I have been using 10.13 since early alphas and XQuartz has been functioning perfectly (including just now when I tried `fix()`. As an aside, it's better to programmatically mutate the data than use something like `fix()` since you get reproducibility as a benefit. – hrbrmstr Dec 20 '17 at 03:11
  • Yes I did use the actual installer before I used the homebrew version and I still got the same problems. I then reinstalled XQuartz with homebrew. I wanted to use `fix()` because it is used in a book that I'm reading. – cod3min3 Dec 20 '17 at 03:16
  • Is XQuartz running when you try to use `fix()`? – hrbrmstr Dec 20 '17 at 03:18
  • How do I do that? What I did try is running the command `x11()` in RStudio, the output was `Error in x11() : X11 is not available` – cod3min3 Dec 20 '17 at 03:28
  • thee's an XQuartz app in `/Applications/Utilities/XQuartz.app`. Open it and then try to use X11 ops in R. It should have opened automatically. Also check https://stackoverflow.com/a/26490114/1457051 – hrbrmstr Dec 20 '17 at 10:48
  • @hrbrmstr I tried doing the command with Xquartz open and the error still occurred. I even tried reinstalling it again through the installer. I also followed the answer in the above link and the same thing happened. I came across [this](https://stackoverflow.com/questions/19009308/cant-use-either-view-or-edit-functions-getting-error-in-external2c-data), I typed `locale` into terminal and all my values were `en_IE.UTF-8` instead of `C` like in the answer. Maybe this is the problem? Also, what other information can I give that help towards solving this problem? – cod3min3 Dec 20 '17 at 12:11
  • 1
    Did you happen to install R via homebrew as well? https://github.com/Homebrew/homebrew-science/issues/5485 suggests it doesn't compile with X11 support out of the box anymore. – hrbrmstr Dec 20 '17 at 12:22
  • @hrbrmstr Yes I did, I uninstalled it and reinstalled it again using the installer from the R website and now it works. Thanks very much! – cod3min3 Dec 20 '17 at 12:35
  • If you're using Homebrew, there's a tap that install R with X11 (and cairo) https://github.com/randy3k/homebrew-r#installing-r-with-x11-support – futtetennista Jun 02 '20 at 19:28

1 Answers1

7

Putting this as an answer in case other find this.

This particular issue was due to using Homebrew R on macOS which (at the time of this Q) didn't compile with X11 support.

I should have had the OP execute capabilities() first. That would have displayed something like:

##       jpeg         png        tiff       tcltk         X11        aqua    http/ftp 
##       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
##    sockets      libxml        fifo      cledit       iconv         NLS     profmem 
##       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
##      cairo         ICU long.double     libcurl 
##       TRUE        TRUE        TRUE        TRUE 

If X11 is FALSE, then you have an R installation w/o support for X11 and should use the macOS R distribution from CRAN.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205