1

How might I write an R output in a file ? I asked this question because I tried to view all output of a data frame with R in terminal, not RStudio, but i got some errors ;

> View(mpg) 

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

So, How might I fix this problem ?

I use MacOS and already installed XQuartz

Thanks for your help

woLfRam
  • 19
  • 3
  • 2
    What type of output file do you want (e.g txt, csv, html)? Your issue may be [this](http://stackoverflow.com/questions/19009308/cant-use-either-view-or-edit-functions-getting-error-in-external2c-data). – desc Sep 15 '16 at 22:07
  • 1
    Does `View()` work on any other datasets? Try `data(cars); View(cars)`. Also just try `Quartz()`. That is the plotting window caller, see if the simple action of calling a plot is the issue. Is this a machine you have administrative control on? 2 things to try if yes, run as admin then run your commands, uninstall reinstall as admin. Sometimes the "soft" install of R acts strange as it doesn't have access to certain registry items. – Badger Sep 15 '16 at 22:08

1 Answers1

0

To redirect all output you can use the sink command. sink("test.log") will redirect all output to test.log, sink(NULL) turns the redirection off again.

snaut
  • 2,261
  • 18
  • 37