I've just committed some code to R-devel to allow clipboard access to non-text in Windows. This was something we discussed last September. I'm not completely happy with the code (it works with numerical clipboard format numbers rather than translating them into their names), but I'd rather make it available than work on it any more. Duncan Murdoch
Wishlist - access non-text from clipboard in Windows
4 messages · Duncan Murdoch, Gabor Grothendieck
2 days later
Hi, I am just trying it now. Suppose I copy the first few lines of the table at: http://www.pricelesswarehome.org/2006/CumulativePL.php into the clipboard by selecting them with the mouse in IE and pressing ctrl-C. Now I can just go to Excel, click on a cell and press ctrl-V and they get pasted as cells. In fact, that is usually what I would do: paste it into Excel and then transfer it to R. Is this correct? readClipboard(49340) # got number from getClipboardFormats() and then parse the HTML that I get from that. I guess what would be nice would be if one could somehow use read.table to read it in and directly get a data frame out. Regards.
On 3/26/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
I've just committed some code to R-devel to allow clipboard access to non-text in Windows. This was something we discussed last September. I'm not completely happy with the code (it works with numerical clipboard format numbers rather than translating them into their names), but I'd rather make it available than work on it any more. Duncan Murdoch
On 3/28/2006 10:08 PM, Gabor Grothendieck wrote:
Hi, I am just trying it now. Suppose I copy the first few lines of the table at: http://www.pricelesswarehome.org/2006/CumulativePL.php into the clipboard by selecting them with the mouse in IE and pressing ctrl-C. Now I can just go to Excel, click on a cell and press ctrl-V and they get pasted as cells. In fact, that is usually what I would do: paste it into Excel and then transfer it to R. Is this correct?
I don't use either IE or Excel, but that sounds plausible.
readClipboard(49340) # got number from getClipboardFormats() and then parse the HTML that I get from that. I guess what would be nice would be if one could somehow use read.table to read it in and directly get a data frame out.
You'll have to write the code for that. As far as I know, 49340 is not a standard clipboard format, so you'll need to look through the IE documentation to find out what's in it. Duncan Murdoch
Regards. On 3/26/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
I've just committed some code to R-devel to allow clipboard access to non-text in Windows. This was something we discussed last September. I'm not completely happy with the code (it works with numerical clipboard format numbers rather than translating them into their names), but I'd rather make it available than work on it any more. Duncan Murdoch
On 3/29/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
On 3/28/2006 10:08 PM, Gabor Grothendieck wrote:
Hi, I am just trying it now. Suppose I copy the first few lines of the table at: http://www.pricelesswarehome.org/2006/CumulativePL.php into the clipboard by selecting them with the mouse in IE and pressing ctrl-C. Now I can just go to Excel, click on a cell and press ctrl-V and they get pasted as cells. In fact, that is usually what I would do: paste it into Excel and then transfer it to R. Is this correct?
I don't use either IE or Excel, but that sounds plausible.
readClipboard(49340) # got number from getClipboardFormats() and then parse the HTML that I get from that. I guess what would be nice would be if one could somehow use read.table to read it in and directly get a data frame out.
You'll have to write the code for that. As far as I know, 49340 is not a standard clipboard format, so you'll need to look through the IE documentation to find out what's in it. Duncan Murdoch
Regards. On 3/26/06, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
I've just committed some code to R-devel to allow clipboard access to non-text in Windows. This was something we discussed last September. I'm not completely happy with the code (it works with numerical clipboard format numbers rather than translating them into their names), but I'd rather make it available than work on it any more. Duncan Murdoch
This seems to work. The next step would be to add functionality
so that one can do:
read.table("clipboard")
and have it automatically figure out what formats are available on the
clipboard and use the appropriate one, which in this case would be
to recognize the HTML table and extract the cells, to get a data.frame
so that the process is as or almost as easy as in Excel.