#From: zk@biocem.univ-bpclermont.fr (Zivan Karaman)
#Subject: Re: [R] Transferring data from S+ to R
#
#I followed the proposed method, and besides the expected trouble (objects
#of user-defined classes, and special objects as .Random.seed, last.warning,
#last.dump, and .Last.value) the only other problem I run into was with "lm"
#objects that were produced with the needed data frame attached, rather than
#by providing it in "data" argument of "lm" function (probably bad practice
#anyway).
#
#As a result of the experience, I've created the following function:
#
#It is self-explanatory; just note that providing NULL as the value for the
#"classes" argument will give you all the objects, regardless of their
#data.class. 
#
#It has been used (I don't dare say tested) with S+ 3.3 and rw0631 only (and
#with NT 4.0).
#The method works for reasonably sized data: I was unable to transfer a 1000
#x 500 matrix, since R ran out of memory (even with --nsize 1000000).
#
#Zivan Karaman
#Limagrain Genetics Research, B.P. 115, 63203 Riom Cedex, France
#Tel: +33 (0) 473 634 343     Fax: +33 (0) 473 634 345
#E-mail: zivan.karaman@biocem.univ-bpclermont.fr

"export" <-
function(file = "s2r", classes = c("function", "data.frame", "list",
"matrix", "numeric", "character", "logical"))
{
	x <- row.names(objects.summary(data.class = classes))
	i <- match(c("last.dump", "last.warning", ".Last.fixed", ".Last.value",
".Random.seed"), x)
	i <- i[!is.na(i)]
	if(length(i) > 0)
		x <- x[ - i]
	dump(x, fileout = file)
}

