Cheryl J Fernandes
2000-Jun-08 18:54 UTC
[Rd] creating models from "Objects" in R's environment
Hi
I'm trying to create Tree based models in R using the downloadable
package called "tree".
It is mentioned in the R documentation that Objects are created and
stored in the R environment by name.
So I have saved all the objects formed during the creation of a tree model
using the R command:
dump(objects(),"Z:\\Project\\Exammples\\Output\\outputTree.txt");
Here's a snapshot of the output file outputTree.txt:
"hc" <-
structure(list(merge = structure(c(-1, -10, -12, -14, -18, -20,
-22, -24, -26, -28, -30, -33, -36, -38, -40, -42, -44, -49, -52,
-54, -56, -58, -60, -62, -64, -66, -68, -72, -74, -77, -80, -84,
-88, -90, -93, -3, -4, -5, -46, -51, -95, -16, -35, -71, -76,
80, 76, 83, 81, 85, 82, 89, 86, 88, 91, 93), .Dim = c(94, 2)),
height = c(0.00099999999999989, 0.00099999999999989,
0.00099999999999989,
0.00099999999999989, 0.00099999999999989, 0.00099999999999989,
0.00099999999999989, 0.00099999999999989, 0.00099999999999989,
0.00099999999999989, 0.00099999999999989, 0.00099999999999989,
0.00099999999999989, 0.00099999999999989, 0.00099999999999989,
0.0389999999999997, 0.0539999999999998, 0.0943398113205659
), order = c(79, 82, 83, 84, 85, 77, 78, 80, 81, 86, 92,
95, 93, 94, 90, 91, 87, 88, 89, 56, 57, 58, 59, 60, 61, 62,
34, 24, 25, 26, 27, 32, 28, 29), labels = c("1", "2",
"3",
"4", "5", "6", "7", "8",
"9", "10", "11", "12", "13",
"14",
"85", "86", "87", "88",
"89", "90", "91", "92", "93",
"94",
"95"), method = "complete", call = hclust(d =
dist(vegtest),
method = "complete"), dist.method = "euclidean"),
.Names c("merge",
"height", "order", "labels", "method",
"call", "dist.method"),
class = "hclust")
"last.warning" <-
structure(list("NAs introduced by coercion" = NULL), .Names =
"NAs
introduced by
coercion")
"v.tr" <-
structure(list(frame = structure(list(var = structure(c(2, 1,
2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1), .Label
c("<leaf>",
"Veg"), class = "factor"), n = c(95, 7, 88, 34, 22, 5, 17,
12,
5, 7, 54, 5, 49, 23, 9, 14, 26, 7, 19), dev c(0.00174753684210526,
.
..
....
After creating the models, one needs to analyse them with some new data.
Hence, I am now trying to analyze this model with a new set of data.
Is it possible in R to recreate the models by reading from the
"Object"
output file.
ie By reading from the above displayed file, can we recreate the tree
model ??
Any help/hints would be highly appreciated.
Thanks much
Cheryl Fernandes
Cheryl Fernandes
Laboratory of Advanced Computing
University of Illinois at Chicago.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2000-Jun-08 19:32 UTC
[Rd] creating models from "Objects" in R's environment
On Thu, 8 Jun 2000, Cheryl J Fernandes wrote:> Hi > I'm trying to create Tree based models in R using the downloadable > package called "tree". > > It is mentioned in the R documentation that Objects are created and > stored in the R environment by name. > > So I have saved all the objects formed during the creation of a tree model > using the R command: > > dump(objects(),"Z:\\Project\\Exammples\\Output\\outputTree.txt"); >[..]> Here's a snapshot of the output file outputTree.txt:> After creating the models, one needs to analyse them with some new data. > Hence, I am now trying to analyze this model with a new set of data. > > Is it possible in R to recreate the models by reading from the "Object" > output file.Eveything is possible in R: you can program a Turing machine in it but you might need unlimited memory.> ie By reading from the above displayed file, can we recreate the tree > model ??Yes, but to fit the *formula* to a new dataset (hence a *new* model) you will need to use update. I suggest you use save() not dump() to store objects. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._