[rkward-cvs] SF.net SVN: rkward:[3357] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Jan 12 09:02:19 UTC 2011


Revision: 3357
          http://rkward.svn.sourceforge.net/rkward/?rev=3357&view=rev
Author:   tfry
Date:     2011-01-12 09:02:18 +0000 (Wed, 12 Jan 2011)

Log Message:
-----------
Allow data.frames to have 0 rows, initially

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/core/rkvariable.cpp
    trunk/rkward/rkward/core/rkvariable.h
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-01-09 12:22:59 UTC (rev 3356)
+++ trunk/rkward/ChangeLog	2011-01-12 09:02:18 UTC (rev 3357)
@@ -1,3 +1,4 @@
+- Fixed: Would crash when trying to edit 0 row data.frame
 - Fixed: Output generated by external processes (system()) was not shown on the console
 - Fixed: Converting a variable to factor in the editor would drop existing levels, silently, and lead to NAs
 - Fixed: Cursor would keep jumping to the end, when typing a filename in the filename selection field in plugins

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2011-01-09 12:22:59 UTC (rev 3356)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2011-01-12 09:02:18 UTC (rev 3357)
@@ -386,7 +386,7 @@
 void RKVariable::extendToLength (int length) {
 	RK_TRACE (OBJECTS);
 
-	if (length <= 0) length = 1;
+	if (length <= 0) length = 0;
 	int old_length = getLength ();
 	if (length <= old_length) return;
 

Modified: trunk/rkward/rkward/core/rkvariable.h
===================================================================
--- trunk/rkward/rkward/core/rkvariable.h	2011-01-09 12:22:59 UTC (rev 3356)
+++ trunk/rkward/rkward/core/rkvariable.h	2011-01-12 09:02:18 UTC (rev 3357)
@@ -172,8 +172,6 @@
 
 /** changes the allocated storage to contain a least length elements. More data may be allocated than acutally needed. This function only ever does upsizing. */
 	void extendToLength (int length);
-/** changes the allocated storage to contain a least getLength elements. More data may be allocated than acutally needed. This function only ever does downsizing. */
-	void downSize ();
 /** takes care of syncing the given range of cells */
 	void cellsChanged (int from_row, int to_row);
 /** writes the given range of cells to the backend (regardless of whether syncing should be immediate) */

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2011-01-09 12:22:59 UTC (rev 3356)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2011-01-12 09:02:18 UTC (rev 3357)
@@ -41,14 +41,15 @@
 
 # function below is only needed to ensure a nice ordering of the columns. Simply adding a new column would be much easier than this.
 ".rk.data.frame.insert.column" <- function (x, label, index=0) {
+	column <- rep (NA, times=dim (x)[2])
 	if ((index == 0) || (index > dim (x)[2])) {	# insert column at end
-		eval (substitute (x[[label]] <<- c (NA)))
+		eval (substitute (x[[label]] <<- column))
 	} else {
 		for (i in dim (x)[2]:index) {
 			eval (substitute (x[i+1] <<- x[[i]]))
 			eval (substitute (names (x)[i+1] <<- names (x)[i]))
 		}
-		eval (substitute (x[index] <<- c (NA)))
+		eval (substitute (x[index] <<- column))
 		eval (substitute (names (x)[index] <<- label))
 	}
 }


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