Revision: 345
          http://svn.sourceforge.net/rpy/?rev=345&view=rev
Author:   warnes
Date:     2007-04-06 09:51:18 -0700 (Fri, 06 Apr 2007)

Log Message:
-----------
Add Tim Churches RPy demo and update link

Modified Paths:
--------------
    trunk/htdocs/documentation.data
    trunk/htdocs/index.data
    trunk/htdocs/index.html

Added Paths:
-----------
    trunk/htdocs/demo/
    trunk/htdocs/demo/faithful_ecdf.png
    trunk/htdocs/demo/faithful_histogram.png
    trunk/htdocs/demo/faithful_qq.png
    trunk/htdocs/demo/rpy_demo.html

Added: trunk/htdocs/demo/faithful_ecdf.png
===================================================================
(Binary files differ)


Property changes on: trunk/htdocs/demo/faithful_ecdf.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/htdocs/demo/faithful_histogram.png
===================================================================
(Binary files differ)


Property changes on: trunk/htdocs/demo/faithful_histogram.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/htdocs/demo/faithful_qq.png
===================================================================
(Binary files differ)


Property changes on: trunk/htdocs/demo/faithful_qq.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/htdocs/demo/rpy_demo.html
===================================================================
--- trunk/htdocs/demo/rpy_demo.html                             (rev 0)
+++ trunk/htdocs/demo/rpy_demo.html     2007-04-06 16:51:18 UTC (rev 345)
@@ -0,0 +1,214 @@
+<html>
+<head>
+<BASE HREF="http://gestalt-system.sourceforge.net/rpy_demo.html";>
+
+<title>A demonstration of RPy</title>
+</head>
+<body bgcolor="white">
+<p><b><a href="http://rpy.sourceforge.net/";>RPy</a></b>, written by Walter 
Moreira, is a Python extension module for using the 
+<a href="http://www.r-project.org";>R programming environment for data analysis 
and graphics</a> from within <a href="http://www.python.org";>Python</a>.
+<p><b><a href="http://rpy.sourceforge.net/";>RPy</a></b> is available from the 
<a href="http://rpy.sourceforge.net/";>RPy project web page</a>.
+As Walter notes, RPy was inspired by <a 
href="http://www.omegahat.org/RSPython/index.html";>RSPython</a> by Duncan 
Temple Lang. RSPython
+allows R to be called from Python <b>and</b> vice-versa (i.e. Python can be 
embedded in R), as well as providing more general facilities for 
+exploiting the object-oriented aspects of both Python and R. However, at least 
for me, RPy is a lot easier to use. It is my sincere hope that
+RPy and RSPython can be merged in a display of el Norte/el Sur co-operation, 
so we can have the best of both.  
+
+<p>The following example provides a small taste of both the power of the R 
environment and the ease with which RPy allows this power to be used from 
within Python.
+<p>The data are eruption times for the Old Faithful geyser which, along with 
Yogi Bear, is located in the Yellowstone National Park in Wyoming, USA.
+The data file <a href="faithful.dat">faithful.dat</a> was exported from the 
faithful example dataset which comes as part of R. The R code in this
+example was borrowed directly from Section 8.2 of "<a 
href="http://cran.r-project.org/manuals.html";>An Introduction to R, Version 
1.4.1</a>" by W.N. Venables, D.M. Smith and the R Development Core Team.
+Minimal changes to the orginal R code were required to make it work from 
within Python, thanks to RPy.
+
+<p>The following Python code (<a href="faithful.py">faithful.py</a>):
+<table>
+<tr bgcolor="yellow">
+<td>
+<pre>
+from rpy import *
+
+faithful_data = {"eruption_duration":[],
+                 "waiting_time":[]}
+                
+f = open('faithful.dat','r')
+
+for row in f.readlines()[1:]: # skip the column header line
+    splitrow = row[:-1].split(" ")
+    faithful_data["eruption_duration"].append(float(splitrow[0]))
+    faithful_data["waiting_time"].append(int(splitrow[1]))
+
+f.close()
+
+ed = faithful_data["eruption_duration"] 
+edsummary = r.summary(ed)
+print "Summary of Old Faithful eruption duration data"
+for k in edsummary.keys():
+    print k + ": %.3f" % edsummary[k]
+print    
+print "Stem-and-leaf plot of Old Faithful eruption duration data"
+print r.stem(ed)
+
+r.png('faithful_histogram.png',width=733,height=550)
+r.hist(ed,r.seq(1.6, 5.2, 0.2), prob=1,col="lightgreen",main="Old Faithful 
eruptions",xlab="Eruption duration (seconds)")
+r.lines(r.density(ed,bw=0.1),col="orange")
+r.rug(ed)
+r.dev_off()
+
+long_ed = filter(lambda x: x > 3, ed)
+r.png('faithful_ecdf.png',width=733,height=550)
+r.library('stepfun')
+r.plot(r.ecdf(long_ed), do_points=0, verticals=1, col="blue",main="Empirical 
cumulative distribution function of Old Faithful eruptions longer than 3 
seconds")
+x = r.seq(3,5.4,0.01)
+r.lines(r.seq(3,5.4,0.01),r.pnorm(r.seq(3,5.4,0.01),mean=r.mean(long_ed), 
sd=r.sqrt(r.var(long_ed))), lty=3, lwd=2, col="red")
+r.dev_off()
+
+r.png('faithful_qq.png',width=733,height=550)
+r.par(pty="s")
+r.qqnorm(long_ed,col="blue")
+r.qqline(long_ed,col="red")
+r.dev_off()
+
+r.library('ctest')
+print
+print "Shapiro-Wilks normality test of Old Faithful eruptions longer than 3 
seconds"
+sw = r.shapiro_test(long_ed)
+print "W = %.4f" % sw['statistic']['W']
+print "p-value = %.5f" % sw['p.value']
+
+print
+print "One-sample Kolmogorov-Smirnov test of Old Faithful eruptions longer 
than 3 seconds"
+ks = r.ks_test(long_ed,"pnorm", mean=r.mean(long_ed), 
sd=r.sqrt(r.var(long_ed)))
+print "D = %.4f" % ks['statistic']['D']
+print "p-value = %.4f" % ks['p.value']
+print "Alternative hypothesis: %s" % ks['alternative']
+print
+</pre>
+</td>
+</tr>
+</table>
+
+<p>produces the following output:
+
+<table>
+<tr bgcolor="yellow">
+<td>
+
+<pre>
+Summary of Old Faithful eruption duration data
+Mean: 3.488
+Median: 4.000
+3rd Qu.: 4.454
+1st Qu.: 2.163
+Min.: 1.600
+Max.: 5.100
+
+Stem-and-leaf plot of Old Faithful eruption duration data
+
+  The decimal point is 1 digit(s) to the left of the |
+
+  16 | 070355555588
+  18 | 000022233333335577777777888822335777888
+  20 | 00002223378800035778
+  22 | 0002335578023578
+  24 | 00228
+  26 | 23
+  28 | 080
+  30 | 7
+  32 | 2337
+  34 | 250077
+  36 | 0000823577
+  38 | 2333335582225577
+  40 | 0000003357788888002233555577778
+  42 | 03335555778800233333555577778
+  44 | 02222335557780000000023333357778888
+  46 | 0000233357700000023578
+  48 | 00000022335800333
+  50 | 0370
+
+None
+
+Shapiro-Wilks normality test of Old Faithful eruptions longer than 3 seconds
+W = 0.9793
+p-value = 0.01052
+
+One-sample Kolmogorov-Smirnov test of Old Faithful eruptions longer than 3 
seconds
+D = 0.0661
+p-value = 0.4284
+Alternative hypothesis: two.sided
+</pre>
+</td>
+</tr>
+</table>
+
+<p>and these graphs:
+
+<p><img src='faithful_histogram.png'>
+<p><img src='faithful_ecdf.png'>
+<p><img src='faithful_qq.png'>
+
+<p>Impressed? I was.
+<p>Cheers,<br><br><a href="mailto:[EMAIL PROTECTED]">Tim Churches</a>
+
+</body>
+
+<SCRIPT language="Javascript">
+<!--
+
+// FILE ARCHIVED ON 20060218110652 AND RETRIEVED FROM THE
+// INTERNET ARCHIVE ON 20070406164800.
+// JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
+// ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
+// SECTION 108(a)(3)).
+
+   var sWayBackCGI = "http://web.archive.org/web/20060218110652/";;
+
+   function xResolveUrl(url) {
+      var image = new Image();
+      image.src = url;
+      return image.src;
+   }
+   function xLateUrl(aCollection, sProp) {
+      var i = 0;
+      for(i = 0; i < aCollection.length; i++) {
+         if (typeof(aCollection[i][sProp]) == "string") { 
+          if (aCollection[i][sProp].indexOf("mailto:";) == -1 &&
+             aCollection[i][sProp].indexOf("javascript:") == -1) {
+            if(aCollection[i][sProp].indexOf("http") == 0) {
+                aCollection[i][sProp] = sWayBackCGI + aCollection[i][sProp];
+            } else {
+                aCollection[i][sProp] = sWayBackCGI + 
xResolveUrl(aCollection[i][sProp]);
+            }
+         }
+         }
+      }
+   }
+
+   xLateUrl(document.getElementsByTagName("IMG"),"src");
+   xLateUrl(document.getElementsByTagName("A"),"href");
+   xLateUrl(document.getElementsByTagName("AREA"),"href");
+   xLateUrl(document.getElementsByTagName("OBJECT"),"codebase");
+   xLateUrl(document.getElementsByTagName("OBJECT"),"data");
+   xLateUrl(document.getElementsByTagName("APPLET"),"codebase");
+   xLateUrl(document.getElementsByTagName("APPLET"),"archive");
+   xLateUrl(document.getElementsByTagName("EMBED"),"src");
+   xLateUrl(document.getElementsByTagName("BODY"),"background");
+   var forms = document.getElementsByTagName("FORM");
+   if (forms) {
+       var j = 0;
+       for (j = 0; j < forms.length; j++) {
+              f = forms[j];
+              if (typeof(f.action)  == "string") {
+                 if(typeof(f.method)  == "string") {
+                     if(typeof(f.method) != "post") {
+                        f.action = sWayBackCGI + f.action;
+                     }
+                  }
+              }
+        }
+    }
+
+
+//-->
+</SCRIPT>
+
+</html>
+

Modified: trunk/htdocs/documentation.data
===================================================================
--- trunk/htdocs/documentation.data     2007-03-24 21:40:01 UTC (rev 344)
+++ trunk/htdocs/documentation.data     2007-04-06 16:51:18 UTC (rev 345)
@@ -26,7 +26,7 @@
            by Titus Brown
          </li>
          <li>
-           <a href="http://gestalt-system.sourceforge.net/rpy_demo.html";>
+           <a href="demo/rpy_demo.html">
              A Demonstration of Rpy</a> by Tim Churches
          </li>
          <li>

Modified: trunk/htdocs/index.data
===================================================================
--- trunk/htdocs/index.data     2007-03-24 21:40:01 UTC (rev 344)
+++ trunk/htdocs/index.data     2007-04-06 16:51:18 UTC (rev 345)
@@ -36,7 +36,7 @@
 
        <p>
                Tim Churches wrote a <a
-                       
href="http://gestalt-system.sourceforge.net/rpy_demo.html";>demo</a>,
+                       href="demo/rpy_demo.html">demo</a>,
                which illustrates the use of RPy.
        </p>
 

Modified: trunk/htdocs/index.html
===================================================================
--- trunk/htdocs/index.html     2007-03-24 21:40:01 UTC (rev 344)
+++ trunk/htdocs/index.html     2007-04-06 16:51:18 UTC (rev 345)
@@ -199,7 +199,7 @@
 
        <p>
                Tim Churches wrote a <a
-                       
href="http://gestalt-system.sourceforge.net/rpy_demo.html";>demo</a>,
+                       href="demo/rpy_demo.html">demo</a>,
                which illustrates the use of RPy.
        </p>
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to