St Avenue Logistic Sdn Bhd
September 22, 2024, 01:26:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SciViews-K, extension for a Komodo R editor  (Read 71 times)
handbagsshop
Newbie
*
Posts: 31


View Profile Email
« on: April 23, 2011, 07:30:14 AM »

# 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() { checkEqualsNumeric(9, Square(3)) checkEqualsNumeric(c(1, 4, 9), Square(1:3)) checkException(Square("xx")) } Cube <- function(x) return(x^3) test(Cube) <- function() { checkEqualsNumeric(27, Cube(3)) checkEqualsNumeric(c(1, 8, 28), Cube(1:3)) # Fails! 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) })
Unit testing with the SciViews-K Unit extension
In R, install the latest version of the svUnit package. This is done with: install.packages("svUnit") 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...,Coach Outlet Stores!) 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.
Download and install R (installers for Linux, Mac OS X universal, Windows, ...; use at least R 2.11.1). Important! You have to install also Tcl/Tk support. In Windows, you have to check Tcl/Tk support. In Mac OS X, this is a separate installer under \tools. Under Linux, check the package installer of your Linux distribution for Tcl/Tk 8.5. Download and install Komodo Edit (installers for Linux, Mac OS X Intel or PowerPC, Windows, ...; use at least Komodo Edit 5.2) Download SciViews-K 0.9.19 (zip archive, 2.6Mb). This is a zip file that contains sciviewsk_0.9.19-ko.xpi, a Komodo extension, and a ReadMe.txt file. Unzip the downloaded file and follow instruction in the ReadMe.txt file We provide also an experimental source tree plugin (zip archive, 16kB). This is the Komodo's source tree plugin with support for listing R functions in a file. Unzip the downloaded file and drag&drop the .xpi file on top of the Komodo window to install it. A 'Source' tab should appear on the left pane and should list all the R functions in the currently edited .R file. Please, report bugs... Once fully tested, we plan to submit R language support to the original source tree plugin distributed on ActiveState. There is also an experimental toolbox for SVN (subversion) support in Komodo Edit (don't use it with Komodo IDE because it already has support for SVN!). Download SVN (0.1.0).kpz and drag&drop the file on top of the Komodo window. Restart Komodo. You need to have access to the svn program on your path and you must be editing files that are located in a correct sVN working directory to use these features. Another experimental toolbox to share code on the web. Download Share code (0.1.0).kpz and drag&drop the file on top of the Komodo window. Restart Komodo. Select code in the editor and click on the "share code" button. Fill in the dialog box and click OK. The link to your shared code is copied to the clipboard. You can send this link to other people. You can also review your shared code, and select which code share to use, among pastebin.mozilla.org or pzt.me. First use
To check that the unit testing framework works and for a quick demo of its features,Coach Outlet Stores, enter the following code in R:
The R reference toolbox and the SciViews snippets of code are major components of SciViews-K and they greatly ease learning/teaching of R. Make sure you understand their logic by looking at this short explanation!
You can explore the various tools in SciViews. Look at the R menu and at the R commands and R objects toolbars. Also look at the R reference collection of R code snippets in the toolbox at right (View -> Tabs & Sidebars -> Toolbox to display it). Also make sure you locate the R Objects explorer. It displays graphically the objects that are currently in R memory. To access it, open the left sidebar with View -> Tabs & Sidebars -> Projects and then, select 'R Objects' in the drop-down menu of that sidebar. The R Objects explorer only display items when R is started and linked to Komodo (R started using the menu R-> Start R). You may want to click the first button in the R Objects explorer toolbar to refresh the tree, but most of the time, refreshing is automatic after each command run in R from Komodo.
Make sure you also look at the various available shortcuts (Help -> List key bindings menu entry). Here are a few R-specific shortcuts added to Komodo by the SciViews-K plugin:
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.
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.
Alt-F1 for contextual R help on the word under the cursor in the editor, or for a snippet in the R reference toolbox Alt-Shift-F1 to search the selected word in R help Ctrl-T (Command-T on the Mac) to expand abbreviation (try typing func, then hit Ctrl-T in a R code Komodo buffer. Look at the toolbox under R reference/|/Abbreviations to see the list of possible abbreviations you can use in R code. Ctrl-Return is the same as Return but it also runs the line of code in R Ctrl-Shift-R to run selection and/or code line by line Ctrl-Shift-F to run the current function Ctrl-Shift-H to run a paragraph (consecutive lines of R code) Ctrl-Shift-M to run code between two bookmarks (define bookmarks first: Code -> Marks -> Toggle Bookmarks, or click on the left margin) 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, ...
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:
Once you have installed all components, close R and Komodo. Then, restart Komodo and start R from within Komodo (menu entry R -> Start R). R should be automatically configured to operate with Komodo. Depending on your firewall settings, you may have a dialog box asking to allow R to act as a server, allow it! Note that R serves only local clients. So, there is no possible intrusion into R from Internet/Intranet. Now,Coach Outlet Stores, you should have a fully operational SciViews-K R GUI.
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:
相关的主题文章:
 
 
   http://www.problock.net/forum/index.php?topic=40114.msg55235#msg55235
 
   http://www.miguelsilva427.eu/forum/index.php?topic=16100.msg27756#msg27756
 
   http://www.sectutor.com/community/index.php?topic=52539.msg85601#msg85601
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
Installed by Installatron
Valid XHTML 1.0! Valid CSS!