[rkward-cvs] SF.net SVN: rkward: [2253] branches/KDE4_port/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Nov 19 21:50:11 UTC 2007


Revision: 2253
          http://rkward.svn.sourceforge.net/rkward/?rev=2253&view=rev
Author:   tfry
Date:     2007-11-19 13:50:11 -0800 (Mon, 19 Nov 2007)

Log Message:
-----------
Merge 2252 from trunk

Modified Paths:
--------------
    branches/KDE4_port/rkward/plugins/analysis/crosstab.php
    branches/KDE4_port/rkward/rbackend/rpackages/rkward/R/public.R

Modified: branches/KDE4_port/rkward/plugins/analysis/crosstab.php
===================================================================
--- branches/KDE4_port/rkward/plugins/analysis/crosstab.php	2007-11-19 21:46:04 UTC (rev 2252)
+++ branches/KDE4_port/rkward/plugins/analysis/crosstab.php	2007-11-19 21:50:11 UTC (rev 2253)
@@ -44,7 +44,7 @@
 	if ($final) { ?>
 for (i in 1:length (results)) {
 	rk.header ("Crosstabs (n to 1)", parameters=list ("Dependent", descriptions[[i]][['Dependent']], "Independent", descriptions[[i]][['Independent']]))
-	rk.print (results[[i]])
+	rk.results (results[[i]], titles=c(descriptions[[i]][['Dependent']], descriptions[[i]][['Independent']]))
 <?		if (getRK_val ("chisq") == "TRUE") { ?>
 
 	rk.header ("Pearson's Chi Square Test for Crosstabs", list ("Dependent", descriptions[[i]][['Dependent']], "Independent", descriptions[[i]][['Independent']], "Method", chisquares[[i]][["method"]]))

Modified: branches/KDE4_port/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- branches/KDE4_port/rkward/rbackend/rpackages/rkward/R/public.R	2007-11-19 21:46:04 UTC (rev 2252)
+++ branches/KDE4_port/rkward/rbackend/rpackages/rkward/R/public.R	2007-11-19 21:50:11 UTC (rev 2253)
@@ -172,6 +172,22 @@
 	sink (rk.get.output.html.file(), append=TRUE)
 	on.exit (sink ())
 
+	# convert 2d tables to data.frames with values labelled
+	if (is.table(x) && (length(dim(x)) == 2)) {
+		rows = dim(x)[1]
+		cols = dim(x)[2]
+		if (is.null(titles)) {
+			titles <- names(dimnames(x))
+		}
+		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]]
+		titles <- c ("", paste (titles[2], "=", names (internal)))
+		x <- temp
+	}
+
 	if (is.list (x)) {	# or a data.frame
 		if (is.null (titles)) {
 			titles <- names (x)


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