Scripting R
Since this part of the thread is more about Excel/R GUI data copying
-- the easiest solution is to use clipboard and it's easily scriptable:
* select a table in Excel
* Copy (<Cmd><C>)
* switch to R and run
read.table(pipe("pbpaste -"),T,"\t")
-- if you didn't include column headers in the paste operation use
instead:
read.table(pipe("pbpaste -"),F,"\t")
Clearly, the above is done best with AS:
tell application "Microsoft Excel" to activate
tell application "System Events"
tell process "Microsoft Excel"
click menu item "Copy" of menu "Edit" of menu bar 1
end tell
end tell
tell application "R"
activate
cmd "read.table(pipe('pbpaste -'),T,'\\t')"
end tell
(You can actually remove the "Microsoft Excel" parts and it will work
with any active app such as Numbers)
Bind to a key and all you have to do is to select your table and hit
that key ...
Cheers,
Simon
On Jan 30, 2009, at 4:53 , Christian Prinoth wrote:
Emiliano, what you suggest I have already implemented, although it is a bit sluggish, especially if moving back and forth big chunks of data. The reason I am looking into this is that on windows platforms in my organization many people are using Excel as a frontend and R as a calculation workhorse. Most people are familiar with organizing and handling data in Excel, and though I agree that complex datasets are better handled directly by R, some tasks work very well with the above mentioned setup. I am currently trying to push for a move to OSX, and having very similar tools available would be of great help and smooth the transition. Christian Prinoth <cp at epsilonsgr.it> Epsilon SGR +39-02-88102355
-----Original Message----- From: Emiliano Guevara [mailto:emiguevara at gmail.com] Sent: 29 January, 2009 20:28 To: Christian Prinoth Cc: r-sig-mac at stat.math.ethz.ch Subject: Re: [R-SIG-Mac] Scripting R Hi! maybe my reply will be too foolish... but I'll try anyway! Can't you just use .CSV as an interface format between any spreadsheet software and R? That makes data sharing really very simple by using read.csv and read.csv2 to get the data into R, and then write.csv and write.csv2 to save for the spreadsheet. I imagine you can easily make an Applescript wrapper to make the transition look a lot more like a GUI feature... but then, why on earth would you need to use something like Excel when you are already using R??? anyway, good luck! E. On Jan 29, 2009, at 17:03 PM, Christian Prinoth wrote:
Hi, is there something similar to rcom on OSX? I understand
that R for OSX
has some limited applescript support, but I was wondering if there is an easy way to share data with other applications. My ultimate
goal would
be to use R together with a spreadsheet as I can currently do on windows with R, rcom and Excel. Thanks Christian Prinoth <cp at epsilonsgr.it> Epsilon SGR +39-02-88102355
************************************************************** ********** Emiliano R. Guevara Department of Linguistics and Scandinavian Studies -- University of Oslo PO Box 1102 Blindern, 0317 Oslo, Norway emiguevara at gmail.com ************************************************************** **********
DISCLAIMER:\ L'utilizzo non autorizzato del presente mes...{{dropped:
16}}
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac