[rkward-cvs] SF.net SVN: rkward: [1074] trunk/rkward/rkward/rbackend/rpackages/rkward/R/ public.R
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sun Jan 7 16:11:07 UTC 2007
Revision: 1074
http://svn.sourceforge.net/rkward/?rev=1074&view=rev
Author: tfry
Date: 2007-01-07 08:11:06 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
Handling for simple vectors in rk.results
Make sure </table> always gets printed, even if there were errors
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2007-01-07 15:53:38 UTC (rev 1073)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2007-01-07 16:11:06 UTC (rev 1074)
@@ -155,37 +155,41 @@
}
cat ("<table border=\"1\">\n<tr>")
- for (i in 1:length (x)) {
- cat ("<td>", titles[i], "</td>", sep="")
- }
- cat ("</tr>\n")
-
- if (is.data.frame (x)) {
- for (row in 1:dim (x)[1]) {
+ try ({ # if anything fails, make sure the "</table>" is still printed
+ for (i in 1:length (x)) {
+ cat ("<td>", titles[i], "</td>", sep="")
+ }
+ cat ("</tr>\n")
+
+ if (is.data.frame (x)) {
+ for (row in 1:dim (x)[1]) {
+ cat ("<tr>")
+ for (col in 1:dim (x)[2]) {
+ cat ("<td>", x[row, col], "</td>", sep="")
+ }
+ cat ("</tr>\n")
+ }
+ } else { # generic list
cat ("<tr>")
- for (col in 1:dim (x)[2]) {
- cat ("<td>", x[row, col], "</td>", sep="")
+ for (col in x) {
+ col <- as.vector (col)
+ cat ("<td>")
+ for (row in 1:length (col)) {
+ if (row != 1) cat ("\n<br/>")
+ cat (col[row])
+ }
+ cat ("</td>")
}
cat ("</tr>\n")
}
- } else { # generic list
- cat ("<tr>")
- for (col in x) {
- col <- as.vector (col)
- cat ("<td>")
- for (row in 1:length (col)) {
- if (row != 1) cat ("\n<br/>")
- cat (col[row])
- }
- cat ("</td>")
- }
- cat ("</tr>\n")
- }
+ })
cat ("</table>\n")
+ } else if (is.vector (x)) {
+ cat ("<h3>", titles[1], ": ", sep="")
+ cat (x)
+ cat ("</h3>")
} else {
stop ("uninmplemented")
- # TODO: handling for vectors.
- # Should probably output a <ul></ul>
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list