send region with function call to R

View: New views
6 Messages — Rating Filter:   Alert me  

send region with function call to R

by Wesley Chen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear ESS users,

I am trying to write a function in .emacs to send region with function call
to R. For example

test = rbind(c(1,2,3),c(4,5,6)) ;

Then I can highlight "test" and send a function call like

str(test)

to R using local keybinding . I am not sure whether it is doable with ESS. I
tried to do something with Rscript but there is no output in Rterm.

------------------------------------------------

Wesley

        [[alternative HTML version deleted]]

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: send region with function call to R

by Erik Iverson-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

On Tue, Oct 20, 2009 at 12:02 PM, Wesley Chen <tjneibor@...> wrote:

> Dear ESS users,
>
> I am trying to write a function in .emacs to send region with function call
> to R. For example
>
> test = rbind(c(1,2,3),c(4,5,6)) ;
>
> Then I can highlight "test" and send a function call like
>
> str(test)
>
> to R using local keybinding .

It's hard for me tell exactly what you want, but is this what you're
looking for?

http://blogisticreflections.wordpress.com/2009/10/01/r-object-tooltips-in-ess/

Full disclosure, this is a blog I run, but I think it is relevant to
this question.

Best Regards,
Erik Iverson

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: send region with function call to R

by Wesley Chen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This looks awesome. I will check it out later.

Originally, I was looking for something similar to ess-evaluate-region, but
rather than sending the region, it sends str("selected region/object") or
names("selected region/object") to R. As you mentioned in your blog, I need
to constantly inspect structures of different objects, thus I would like to
write some lisp functions and keybinding to speed up my frequent function
calls. Hope it makes me clearer.


On Tue, Oct 20, 2009 at 10:56 AM, Erik Iverson <erikriverson@...>wrote:

> Hello,
>
> On Tue, Oct 20, 2009 at 12:02 PM, Wesley Chen <tjneibor@...> wrote:
> > Dear ESS users,
> >
> > I am trying to write a function in .emacs to send region with function
> call
> > to R. For example
> >
> > test = rbind(c(1,2,3),c(4,5,6)) ;
> >
> > Then I can highlight "test" and send a function call like
> >
> > str(test)
> >
> > to R using local keybinding .
>
> It's hard for me tell exactly what you want, but is this what you're
> looking for?
>
>
> http://blogisticreflections.wordpress.com/2009/10/01/r-object-tooltips-in-ess/
>
> Full disclosure, this is a blog I run, but I think it is relevant to
> this question.
>
> Best Regards,
> Erik Iverson
>

        [[alternative HTML version deleted]]

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: send region with function call to R

by Dan Davison :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Wesley Chen <tjneibor@...> writes:

> This looks awesome. I will check it out later.
>
> Originally, I was looking for something similar to ess-evaluate-region, but
> rather than sending the region, it sends str("selected region/object") or
> names("selected region/object") to R. As you mentioned in your blog, I need
> to constantly inspect structures of different objects, thus I would like to
> write some lisp functions and keybinding to speed up my frequent function
> calls. Hope it makes me clearer.

Hi Wesley,

This is just a quick hack, but does this help as a starting point?

(defun ded/ess-execute-command-on-region (cmd)
  (interactive "sEnter function name: \n")
  (ess-execute
   (concat cmd "(" (buffer-substring (point) (mark)) ")")))

Dan

>
>
> On Tue, Oct 20, 2009 at 10:56 AM, Erik Iverson <erikriverson@...>wrote:
>
>> Hello,
>>
>> On Tue, Oct 20, 2009 at 12:02 PM, Wesley Chen <tjneibor@...> wrote:
>> > Dear ESS users,
>> >
>> > I am trying to write a function in .emacs to send region with function
>> call
>> > to R. For example
>> >
>> > test = rbind(c(1,2,3),c(4,5,6)) ;
>> >
>> > Then I can highlight "test" and send a function call like
>> >
>> > str(test)
>> >
>> > to R using local keybinding .
>>
>> It's hard for me tell exactly what you want, but is this what you're
>> looking for?
>>
>>
>> http://blogisticreflections.wordpress.com/2009/10/01/r-object-tooltips-in-ess/
>>
>> Full disclosure, this is a blog I run, but I think it is relevant to
>> this question.
>>
>> Best Regards,
>> Erik Iverson
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> ESS-help@... mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: send region with function call to R

by Wesley Chen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Erik,

I tried to put your code into .emacs file and load it. But C-c C-g gives me
error:

Symbol's function definition is void: tool-tip-show-at-point

I tried to save the function as

/usr/share/emacs/22.1/site-lisp/ess-R-object-tooltip.el,

Still did not work.

Here is my emacs version
 22.1.1 (x86_64-pc-linux-gnu)

Did I do anything wrong?

Wesley


On Tue, Oct 20, 2009 at 10:56 AM, Erik Iverson <erikriverson@...>wrote:

> Hello,
>
> On Tue, Oct 20, 2009 at 12:02 PM, Wesley Chen <tjneibor@...> wrote:
> > Dear ESS users,
> >
> > I am trying to write a function in .emacs to send region with function
> call
> > to R. For example
> >
> > test = rbind(c(1,2,3),c(4,5,6)) ;
> >
> > Then I can highlight "test" and send a function call like
> >
> > str(test)
> >
> > to R using local keybinding .
>
> It's hard for me tell exactly what you want, but is this what you're
> looking for?
>
>
> http://blogisticreflections.wordpress.com/2009/10/01/r-object-tooltips-in-ess/
>
> Full disclosure, this is a blog I run, but I think it is relevant to
> this question.
>
> Best Regards,
> Erik Iverson
>

        [[alternative HTML version deleted]]

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: send region with function call to R

by Vitalie S. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 20 Oct 2009 19:56:43 +0200, Erik Iverson <erikriverson@...>  
wrote:

> Hello,
>
> On Tue, Oct 20, 2009 at 12:02 PM, Wesley Chen <tjneibor@...> wrote:
>> Dear ESS users,
>>
>> I am trying to write a function in .emacs to send region with function  
>> call
>> to R. For example
>>
>> test = rbind(c(1,2,3),c(4,5,6)) ;
>>
>> Then I can highlight "test" and send a function call like
>>
>> str(test)
>>
>> to R using local keybinding .
>
> It's hard for me tell exactly what you want, but is this what you're
> looking for?
>
> http://blogisticreflections.wordpress.com/2009/10/01/r-object-tooltips-in-ess/
Very nice Erik, thanks.
One thing though, the tooltip pops up at mouse point, which could be  
anywhere (in the other monitor, in my case, which is turned off). Also  
there is no way to make the tooltip to disappear before the 3secs, or so,  
have elapsed.
  How about having the output in the minibufer?

Thanks,
Vitalie.

>
> Full disclosure, this is a blog I run, but I think it is relevant to
> this question.
>
> Best Regards,
> Erik Iverson
>
> ______________________________________________
> ESS-help@... mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

______________________________________________
ESS-help@... mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help