Menu

Executing R scripts in Npp

sudhir22
2008-12-23
2013-05-08
  • sudhir22

    sudhir22 - 2008-12-23

    Hi,

    Thanks for the package. I can see the R syntax highlighting now. Could you please tell me how to execute the commands/script ? i.e., I want to know how to pass the commands to Rgui.

    Thanks,
    Sudhir.

     
    • Andrew Redd

      Andrew Redd - 2008-12-27

      for the basic install without changing any options the following commands are defined:

      F8: pass code to R.  Will start R if not started and is registered in the registry.
      Ctrl+F8: Passes entire file to R.
      Ctrl+Shift+F8: run current file as a batch file. Will save if file is currently modified.

      The about dialog should have all this information and will change if changes are made through the ini settings.

       
    • sudhir22

      sudhir22 - 2008-12-29

      Thanks halpo.

       
    • sudhir22

      sudhir22 - 2009-01-02

      Thanks halpo.

       
    • ptyk

      ptyk - 2009-02-09

      Hello,

      I have got problems with passing codes to R. Can it be because of versions of the software I use? R 2.81, Notepad++ 5.1.4.

      I have edited npptor.ini file, adding R="C:\Program Files\R\R-2.8.1\bin\Rgui.exe" in [executables] part.
      I see highlited text of R scripts in Notepad++, but pressig F8 has no effect and CTRL-F8 returns the message "Could nor [sic!] start or find R. Please check you [sic!] installation or start R manually." (take a look at mistakes in the message text, by the way). I cannot figure out what is wrong.

       
    • ptyk

      ptyk - 2009-02-09

      Hello,

      I have got problems with passing codes to R. Can it be because of versions of the software I use? R 2.81, Notepad++ 5.1.4.

      I have edited npptor.ini file, adding R="C:\Program Files\R\R-2.8.1\bin\Rgui.exe" in [executables] part.
      I see highlited text of R scripts in Notepad++, but pressig F8 has no effect and CTRL-F8 returns the message "Could nor [sic!] start or find R. Please check you [sic!] installation or start R manually." (take a look at mistakes in the message text, by the way). I cannot figure out what is wrong.

       
      • Andrew Redd

        Andrew Redd - 2009-02-09

        There are a few things that you should check.  First make sure that you are running R in the Single Document Interface (SDI) mode.  You can set R to run in SDI during the install.  After installing you can change to the Single Document Interface by the menu command Edit>'Gui Preferences'.  Change to SDI save and restart.

        Your versions of the files are just fine.  There can be a problem on much earlier Notepad++ versions.  The only requirement for R is the SDI mode.

        Let me know if these fix it or if there is still a problem.

         
        • ptyk

          ptyk - 2009-02-11

          Everything is set as it should be. It must be something in the programs installed on this particular machine. I made the same configuration on another one and it works excellent. If I spot what prevents NppToR from recognizing R, I will let you know.

           
  • grotos

    grotos - 2010-10-22

    I've got a question but not strictly about npptor.
    I want to use NppExec plugin instead of npptor. I just want to know what to insert as a command. The behavior should duplicate CTRL+F8 (as in npptor). Looking for it in google is not easy, as everything directs at npptor.

     
  • Andrew Redd

    Andrew Redd - 2010-10-22

    For NppExec use

    set  rcmd = "C:\program files\R\bin\x64\Rcmd.exe"
    npp_run $(rcmd) "$(fullcurrentpath)"
    --
    pretty simple.  or you can also use Rscript as well.
    --
    set Rscript  = "C:\program file\R\R-2.12.0\bin\Rscript.exe"
    Npp_Run $(Rscript) "$(FullCurrentPath"


     
  • ammon lymphater

    ammon lymphater - 2010-11-14

    CTRL+ALT+F8 not working for me
    using the current (2.5) version of NppToR, using default settings; with R 2.11/2.12. On WInXP and Win7
    CTRL+F8 works as designed
    when CTRL+ALT+F8  pressed, I get a dialog box 'TestNPPtoR.Rout does note exist - create it?'
    after pressing yes I end up with the empty file.
    The file that should be created by cat(file=xxx) does not exist either.
    All that suggesting that the script is not executed.

    What am I doing wrong?

    P.S. Great job - doing 90% of what needed in much smaller amount of code than other tools.
    P.P.S. To consider:
      - giving somehow a possiblity to sent lines to R with 'source'  instead of copy/paste - to reduce clutter
      - far-out: send lines between two consecutive bookmarks - that really reduces the number of clicks/keyboard ops

    === the test program
    setwd("c:/temp")
    for(i in 1:(10^7)) if ( (i%%10^6)==0 ) cat(file="testnpptor.log", append=T,"i ",i,proc.time(),"\n")
    === end of test program

     
  • Andrew Redd

    Andrew Redd - 2010-11-15

    @ammon-lymphater Thank you.  The running by script is indeed not running for me as well.  I will investigate and get a patch out soon.  This is probably a regression with the changes that I had to make for the new structure for R 2.12.

    As far reducing clutter consider the silent transfer alt+F8.  It requires the rcom package installed and there is some additional setup for that but it will clean up your sessions.

    The pass between bookmarks is not possible in the current framework, but some things like that would be nice if I decide to change the framework to integrate more tightly with Notepad++.

     

Log in to post a comment.