[R] R and ViM
Bill West
wjwest at CLEMSON.EDU
Wed Apr 19 21:20:04 CEST 2006
Here is my solution for integrating R and Vim. It uses the rcom library and
Vim's perl functionality. Improvements or suggestions are appreciated!
#######
The following is my r.vim file. This requires the rcom library in R.
perl << EOF
sub sendtor
{
use Win32::OLE;
my @pos = $curwin->Cursor();
my $coms = $curbuf->Get($pos[0]);
my @coms = split /\n/ , $coms;
VIM::Msg($coms[0]);
my $R = Win32::OLE->GetActiveObject('RCOMServerLib.StatConnector')
|| Win32::OLE->new('RCOMServerLib.StatConnector');
$R->EvaluateNoReturn( "cat('> " . $coms[0] . "\n')");
unless ( $coms[0] =~ /<-/ || $coms[0] =~ /print/ )
{
$coms[0] = "print(" . $coms[0] . ")";
}
my $temp = $R->Evaluate( $coms[0] );
$R->Close;
}
EOF
function! Rcom()
perl sendtor
endfunction
function! Rinit()
!start rgui
endfunction
map <F11> <Esc>:call Rcom()<cr>j
map <F12> <Esc>:call Rinit()<cr>
--Bill
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Martin Maechler
Sent: Wednesday, April 19, 2006 2:42 AM
To: Jose Quesada
Cc: r-help at stat.math.ethz.ch; Michael Graber
Subject: Re: [R] R and ViM
>>>>> "PD" == Peter Dalgaard <p.dalgaard at biostat.ku.dk>
>>>>> on 19 Apr 2006 01:06:02 +0200 writes:
PD> "Jose Quesada" <quesada at gmail.com> writes:
>> Hmm, how timely.
>>
>> I posted yesterday my solution to integrate R and
>> vim. The message is in my sent box but I don't think it
>> showed up in the list... Here it is again:
>>
>> Hi All,
>>
>> If you use vim to edit R code, you may be interested in
>> this. I have put together a personalized syntax file,
>> some code templates, and a way to send code from Vim to R
>> using autoHotKeys (windows).
>>
>> http://www.andrew.cmu.edu/user/jquesada/RvimSuite/instructions.html
>>
>> Actually, the little autoHotKeys can be useful even if
>> you don't use vim just to send the example R code from
>> the help pages to the console.
>>
>> Best wishes, -Jose
>>
>> PS: @list moderators Any idea why my message (from a
>> @gmail account) appeared in the sent box but never on the
>> list?
PD> I saw it the first time... Could it be that your mail
PD> reader is set up to ignore mail from yourself?
PD> Rather than resending stuff, it is preferable to check
PD> the archives
PD> https://stat.ethz.ch/pipermail/r-help/2006-April/date.html
PD> https://stat.ethz.ch/pipermail/r-help/2006-April/092457.html
PD> which are easily reachable via
>> > R-help at stat.math.ethz.ch mailing list >
>> https://stat.ethz.ch/mailman/listinfo/r-help
Indeed. Please do check the archives.
Now back to the subject: Jose, I think your main contribution is based on
"autoHotKeys" and that only works on Windoze, right?
Michael explicitly mentioned he's working in Mac OS X.
Martin
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list