[rkward-cvs] SF.net SVN: rkward:[3672] trunk/rkward/rkward/rbackend/rpackages/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sat Jun 4 11:48:57 UTC 2011
Revision: 3672
http://rkward.svn.sourceforge.net/rkward/?rev=3672&view=rev
Author: tfry
Date: 2011-06-04 11:48:57 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Add semi-automatic printing of row-names to rk.results()
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.results.Rd
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2011-06-04 11:25:51 UTC (rev 3671)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R 2011-06-04 11:48:57 UTC (rev 3672)
@@ -230,7 +230,7 @@
cat ("<br>\n")
}
-"rk.results" <- function (x, titles=NULL) {
+"rk.results" <- function (x, titles=NULL, print.rownames) {
sink (rk.get.output.html.file(), append=TRUE)
on.exit (sink ())
@@ -243,14 +243,20 @@
}
rn <- c () # row names
for (row in 1:rows) rn[row] <- paste (titles[1], "=", dimnames(x)[[1]][row])
- internal <- data.frame (cbind (x))
- temp <- data.frame (as.character (rn), stringsAsFactors=FALSE)
- for (col in 1:cols) temp[[col+1]] <- internal[[col]]
+ x <- data.frame (cbind (x))
+ rownames (x) <- as.character (rn)
titles <- c ("", paste (titles[2], "=", names (internal)))
- x <- temp
}
if (is.list (x)) { # or a data.frame
+ if (is.data.frame (x)) {
+ # by default, print rownames, unless they are just plain row numbering
+ if (missing (print.rownames)) print.rownames <- !isTRUE (all.equal (rownames (x), as.character (1:dim(x)[1])))
+ if (isTRUE (print.rownames)) {
+ x <- cbind (rownames (x), x)
+ names (x)[1] <- '';
+ }
+ }
if (is.null (titles)) {
titles <- names (x)
}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.results.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.results.Rd 2011-06-04 11:25:51 UTC (rev 3671)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.results.Rd 2011-06-04 11:48:57 UTC (rev 3672)
@@ -17,7 +17,7 @@
rk.print.literal(x)
rk.print.code(code)
rk.header(title, parameters = list(), level = 1)
-rk.results(x, titles = NULL)
+rk.results(x, titles = NULL, print.rownames)
rk.describe.alternative(x)
}
@@ -28,6 +28,7 @@
\item{level}{an integer, header level. For example, \code{level=2} creates the header with \code{<h2></h>} tag.}
\item{parameters}{a list, preferably named, giving a list of "parameters" to be printed to the output}
\item{titles}{a character vector, giving the column headers for a html table.}
+\item{print.rownames}{controls printing of rownames. TRUE to force printing, FALSE to suppress printing, omitted (default) to print rownames, unless they are plain row numbers.}
}
\details{
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