[R] Handling the windows clipboard/32KB limit

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Sep 9 12:41:12 CEST 2004

On Thu, 9 Sep 2004, Ritter, Christian C MCIL-CTANL/S wrote:

> (R 1.9.1; Windows 2000;)
> I'm just comparing ease of use, speed, etc for methods of transferring
> data frames in the Excel, MySQL, R triangle. It turns out that going
> from Excel to R (when doing this carefully). Using the clipboard is
> actually quite fast and efficient (2 seconds for transferring 120 000
> cells on a common desktop computer as compared to much longer for going
> the RODBC route, maybe also substantially longer using the R(D)COM
> route). Other advantage: Relatively flexible handling of missing values
> from Excel which may be "empty", "#N/A", etc. 

You clearly haven't looked at RODBC carefully as that has equally flexible 

> So I thought I would also look at ways of going back via the clipboard.
> There I'm hitting a funny snag. The documentation explains that there is
> a 32KB limit on writing to the clipboard. This may make sense as a
> default, but does it make sense as a hard restriction?

I guess you are talking about using file="clipboard" in a connection, but
there is also writeClipboard, whose documentation does not mention a 

My Windows documentation says there is a 32Kb limit on the size of an 
text object put on the clipboard, and I believe that is the case for
Windows 95/98/ME at least.  So a hard restriction makes sense.

> Any ideas of getting around this limitation (besides cumbersome R-code
> buffering/breaking up the frame to send into small pieces to be
> collected and assembled in Excel?

R is Open Source, so this is an opportunity for you to experiment, test on 
various versions of Windows and contribute a patch back to the R project.

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