Layui

Can't use either View() or edit() functions, getting “Error in .External2(C_dataviewer, x, title) : invalid device” error message

问题:

I'm running R through the Terminal in a Mac OSX Snow Leopard system.

I get this error message when trying to use View():

Error in .External2(C_dataviewer, x, title) : invalid device In addition: Warning messages: 1: In View(a) : locale not supported by Xlib: some X ops will operate in C locale 2: In View(a) : X cannot set locale modifiers 3: In View(a) : unable to create fontset --fixed-medium-r----120------

And this error message when trying to use edit():

Error in .External2(C_dataentry, datalist, modes) : invalid device In addition: Warning messages: 1: In edit.data.frame(a) : locale not supported by Xlib: some X ops will operate in C locale 2: In edit.data.frame(a) : X cannot set locale modifiers 3: In edit.data.frame(a) : unable to create fontset --fixed-medium-r----120------

I can't find information about this particular problem. What can I do to fix this?

sessionInfo() returns:

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] C/UTF-8/C/C/C/C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

回答1:

The problem might be your locale settings. Run command 'locale' from terminal and see if there are any lines with something else but 'C' locale. For example, in my case output is like this:

macbook:foo user$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Easiest way to solve this is to set the locale to be C for just the R process ie. run R from terminal session with command 'LC_CTYPE=C R' instead of just 'R'. At least on OS/X 10.6.8 this gets rid of the error messages and allows R to display the edit window.



回答2:

The cause for my problem: View(dataset) in the rchunk where we load up data.

I had it here because I loaded in data like data <-read_excel("name") And had View there because I copied and pasted it from my console, but it's not needed.