[R] write to clipboard under Linux
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Oct 31 14:34:06 CET 2006
On Sun, 29 Oct 2006, Johannes Hüsing wrote:
> Dear all,
> I am trying to use the clipboard when writing a table.
> Typing:
>
> write.table(object, file="clipboard")
>
> leads to the message:
>
> Fehler in file(file, ifelse(append, "a", "w")) :
> 'mode' für die Zwischenablage muss unter Unix 'r' sein
>
> My interpretation is that I am not allowed to write into the
> clipboard from a program called from R. Is there a way to
> change this behaviour?
Linux does not have a clipboard but an X11 session has primary and
secondary selections. ?file says
Clipboard:
'file' can also be used with 'description = "clipboard"' in mode
'"r"' only. It reads the X11 primary selection, which can also be
specified as '"X11_primary"' and the secondary selection as
'"X11_secondary"'.
When the clipboard is opened for reading, the contents are
immediately copied to internal storage in the connection.
Unix users wishing to _write_ to the primary selection may be able
to do so via 'xclip' (<URL:
http://people.debian.org/~kims/xclip/>), for example by
'pipe("xclip -i", "w")'.
so RTFM applied. Writing to an X11 selection needs multiple threads and I
did not think it worth the very considerable effort of implementing
(unlike for Windows).
Note that window managers may have other clipboards, and for example the
RGtk2 package has interfaces to gtk clipboards.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list