SciViews-K


SciViews-K is an extension for Komodo Edit to transform it into a R editor and GUI. SciViews-K screenshot

(SciViews-K and SciViews-K Unit in Komodo on Mac OS X - click on the picture to enlarge)

Installation

Jul 06, 2008

To use SciViews-K, you have to install four components: R, Komodo Edit, the SciViews-R additional packages in R, and the SciViews-K extension in Komodo:

  • Download and install R (installers for Linux, Mac OS X universal, Windows, ...)
  • Download and install Komodo Edit (installers for Linux, Mac OS X Intel or PowerPC, Windows, ...)
  • Download the SciViews-K Komodo extension (do not double-click on the link, but right-click and then, save link as...). To install the downloaded file, just open it on Komodo Edit, or drag and drop it in the Komodo window. You will be prompted to restart Komodo. On restart, a directory where the SciViews-K toolbox can be extracted is then asked. Select any directory. Then, if you don't see 'R' and 'Web' menus at the right of the menubar in Komodo, restart it manually once again. For those who installed older versions, make sure you delete any ancient 'SciViews-K x.y.z' folders from your Komodo toolbox! (View -> Tabs -> Toolbox then right-click on the item you want to eliminate and select Delete).
  • To install R packages and configure R properly, start it from Komodo. Use the menu entry R -> Start R -> R app (Mac)|R gui (Windows)|R terminal. R starts and is configured. When it is done, you should see a message: "R is SciViews ready!". Note that you can only use 'R terminal' under Linux, and under Mac OS X, you must install R in /Applications to be able to use the R app (Mac) menu entry.

Warning: SciViews-K is still in development (alpha, unstable) version in its current stage! Of course, installation procedure will be further simplified in the final version.

First use

Jun 24, 2008

With SciViews-R/SciViews-K, R and Komodo are communicating together by using sockets. In the current version, the respective socket servers only allow connections from local clients, meaning that both R and Komodo Edit must run on the same machine. This constraint is easy to unlock, but we would prefer to build security transactions in these server before unleashing distant connections.

The Komodo socket server listens on port 7052 by default, and is ready as soon as Komodo with the SciViews-K extension is started. The R socket server must be installed in R, listening on port 8888 (default port). To establish the communication, you start R from Komodo. You can also install it in R (started independently) with the following command:

options(ko.serve = 8888); require(svGUI)

Now, you should have a fully operational SciViews-K R GUI. Providing you start the socket server in R each time you start it, you can safely close and restart R, or Komodo. It does not break the communication between the two. Also, it does not matter which program you start first.

You can explore the various tools in the 'SciViews-K' folder in your toolbox, and in the R menu and toolbar in Komodo Edit. Make sure you look also at the shortcuts (Help -> List key bindings menu entry). Here are a few specific shortcuts added to start with:

  • Shift-F1 for contextual help on the word under the cursor in the editor
  • Alt-Shift-F1 for help search selected word (make sure to look at the Web menu too)
  • Ctrl-T to expand abbreviation (try typing func, then hit Ctrl-T in a file previously saved with a .R extension; a tooltip also appears when the sequence you type corresponds to a recognize abbreviation... and there are dozens of them already defined!)
  • Ctrl-Return is the same as Return but also run the line of code in R
  • Ctrl-Shift-R to run selection and/or code line by line
  • Ctrl-Shift-A to run all code in the current document in R
  • Ctrl-Shift-H to run a paragraph (consecutive lines of R code)
  • Ctrl-Shift-M to run code between two bookmarks (define bookmarks first!)
  • Ctrl-Shift-S to summarize the object whose name is under the cursor
  • Ctrl-Shift-L to plot the object whose name is under the cursor
  • F3 to search next occurence of the word under the cursor
  • F4 to list R objects in memory (in .GlobalEnv)
  • F7 to set the R working directory to the dir of the current edited file in Komodo
  • etc, etc, ...

Warning: The socket server in R uses Tcl/Tk. Hence, you must ensure that you can use the 'tcltk' package in R, and install all required components. Under Windows, everything is installed for you if you select the corresponding features in the installer. For other OSes, consult the R ReadMe and FAQ files in case of problems. For Mac OS X 10.4 (Tiger), you have to start X11 manually before the 'tcltk' package can be loaded. The provided 'Rprofile' (see here above) does everything for you, including starting X11 under Mac OS X 10.4 if needed.

Note: The object explorer ('R Objects' tab at left) is not complete in version 0.6.1 of SciViews-K. It doesn't work well and this is just because it is not finished yet! Do not send bug reports for this component yet, please!

Unit testing with the SciViews-K Unit extension

Jul 03, 2008

SciViews now provides a complete unit testing framework for R, including a GUI component in Komodo/SciViews-K. To install it, first make sure you have a fully working Komodo with SciViews-K installation. You must install additional components in R (the svUnit package), and in Komodo (the SciViews-K Unit extension). Here are the steps to install these components:

  • In R, install the latest development version of the svUnit package from R-Forge. This is done with:
install.packages("svUnit", repos = "http://R-Forge.R-project.org")
  • Make sure R is running with its socket server, and run Komodo with the SciViews-K extension correctly installed. Load the svUnit package in R using library(svUnit). The package automatically detects any valid communication with Komodo and check if the SciViews-K Unit extension is installed and its version is correct. If it is not the case (the extension is not installed yet, at this stage), Komodo will propose you to install it. Click Install now and restart Komodo.
  • Sometimes, this automatic installation process fails (depending on the security options selected in Mozilla). In this case, you can install the extension manually by downloading it here (right-click on the link and make Save as...!) and installing it manually in Komodo. The easiest way is to drag and drop the downloaded file on the Komodo window, or to open that file in Komodo.

To check that the unit testing framework works and for a quick demo of its features, enter the following code in R:

# Reveal example unit tests in svUnit package options(svUnit.excludeList = NULL) # Create two functions that include their test cases Square <- function(x) return(x^2) test(Square) <- function() { checkEquals(9, Square(3)) checkEquals(c(1, 4, 9), Square(1:3)) checkException(Square("xx")) } Cube <- function(x) return(x^3) test(Cube) <- function() { checkEquals(27, Cube(3)) checkEquals(c(1, 8, 28), Cube(1:3)) # This test should fail! checkException(Cube("xx")) } # A separate test case function (not attached to a particular object) # This is the simplest way to loosely define quick and durty integration tests test_Integrate <- svTest(function() { checkTrue(1 < 2, "check1") v <- 1:3 # The reference w <- 1:3 # The value to compare to the reference (trivial) checkEquals(v, w) })

Now, you should have a couple of entries in the top list of the 'R Unit' tab in the right panel in Komodo (open it with the menu entry View -> Tabs -> R Unit). If not, click the refresh button (two green arrows pointing in opposite directions). If you click the 'Run' button, all the selected tests are run and a hierarchical, browsable report appears at the bottom of the 'R Unit' tab. Move your cursor on top of its entries to get more info, and double click these entries to open the corresponding test unit file with the cursor located at the beginning of the corresponding test function in the Komodo editor.

There is a manual describing svUnit in details. You can download it from here (zipped .pdf, 412kB).

Clean up and/or uninstall

Jul 06, 2008

If you have multiple menu entries 'R' and 'Web', you have multiple SciViews-K x.y.z folders in your toolbox (it is perfectly normal to have two 'R' entries inside this folder with different icons: one defines the 'R' menu and the other one defines the 'R' toolbar). Always delete old 'SciViews-K x.y.z' folders before or just after installing a new version of these toolbox. To remove duplicated folder entries in the toolbox, do the following in Komodo:

  • Menu View -> Tabs -> Toolbox to display the toolbox at right
  • Locate the older 'SciViews-K x.y.z' folders in this toolbox and delete it completely: right click on it, then choose Delete in the context menu, and confirm complete deletion. Note: never change items in the 'SciViews-K x.y.z' folder. Move or copy items you want to change elsewhere.
  • Restart Komodo

To uninstall SciViews-K and SciViews-K Unit completely, eliminate all 'SciViews-K x.y.z' entries in the toolbox as explained hereabove, then:

  • Open the extension manager (menu Tools-> Extension Manager
  • Locate the 'SciViews-K' and 'SciViews-K Unit' entries in the list and click Uninstall
  • Restart Komodo

Question? Suggestion? Bug report?

Jun 28, 2008

If you have any question about SciViews-K, send an email to support@sciviews.org. For bug report, suggestions, feature requests, or for proposing a patch, please, use the SciViews R-Forge tracker.

You have access to the latest development version of SciViews-K here, in the /komodo subdirectory. You could also be interested by the SciViews-commits mailing list if you want to closely follow its developments.