[rkward-cvs] SF.net SVN: rkward: [1049] trunk/rkward/rkward/rbackend/rpackages/rkward/R/ public.R

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Jan 2 15:50:00 UTC 2007


Revision: 1049
          http://svn.sourceforge.net/rkward/?rev=1049&view=rev
Author:   tfry
Date:     2007-01-02 07:50:00 -0800 (Tue, 02 Jan 2007)

Log Message:
-----------
Extend rk.results to handle ragged lists, make rk.get.description smarter

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-02 14:30:56 UTC (rev 1048)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R	2007-01-02 15:50:00 UTC (rev 1049)
@@ -1,10 +1,11 @@
 # retrieve the rkward label (if any) of the given object
 "rk.get.label" <- function (x) {
 	if (is.call (x) || is.name (x)) {
-		as.vector (attr (eval (x), ".rk.meta")[names (attr (eval (x), ".rk.meta")) == "label"])
+		ret <- attr (eval (x), ".rk.meta")[names (attr (eval (x), ".rk.meta")) == "label"]
 	} else {
-		as.vector (attr (x, ".rk.meta")[names (attr (x, ".rk.meta")) == "label"])
+		ret <- attr (x, ".rk.meta")[names (attr (x, ".rk.meta")) == "label"]
 	}
+	as.character (as.vector (ret))
 }
 
 # get a short name for the given object
@@ -50,7 +51,7 @@
 			shortname <- .rk.make.short.name (argnames[i])
 		}
 
-		if (is.null (lbl)) descript[i] <- shortname
+		if (is.null (lbl) || (length (lbl) < 1)) descript[i] <- shortname
 		else descript[i] <- paste (shortname, " (", lbl, ")", sep="")
 	}
 
@@ -152,12 +153,13 @@
 			titles <- names (x)
 		}
 
+		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)) {
-			cat ("<table border=\"1\">\n<tr>")
-			for (i in 1:length (x)) {
-				cat ("<td>", titles[i], "</td>", sep="")
-			}
-			cat ("</tr>\n")
 			for (row in 1:dim (x)[1]) {
 				cat ("<tr>")
 				for (col in 1:dim (x)[2]) {
@@ -165,12 +167,20 @@
 				}
 				cat ("</tr>\n")
 			}
-			cat ("</table>\n")
-		} else {
-			stop ("uninmplemented")
-			# TODO: handling for regular lists. 
-			# Should probably output a <ul></ul>
+		} 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 {
 		stop ("uninmplemented")
 		# TODO: handling for vectors. 


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