Skip to content
Prev 268112 / 398502 Next

convert a splus randomforest object to R

In Splus the randomForest package version is 4.5-18; in R randomForest
version is 4.6-2. I'm using R version 2.13.1.

After restore the randomForest object into R using data.restore(), below
are str(cost.rf) outputs,

List of 17
 $ call           : language randomForest(x =
train.roughfix[stop("Argument '' is missing"),      -1L], y =
train.roughfix[stop("Argument '' is missing"),  ...
 $ type           : chr "regression"
 $ predicted      : atomic [1:51368] 23921 8884 2799 4432 7201 ...
  ..- attr(*, ".Names")= chr [1:51368] "1" "2" "3" "4" ...
 $ mse            : num [1:500] 1.65e+09 9.76e+08 7.70e+08 6.77e+08
6.22e+08 ...
 $ rsq            : num [1:500] -1.952 -0.747 -0.379 -0.213 -0.114 ...
 $ oob.times      : int [1:51368] 185 190 189 176 182 184 164 200 189
200 ...
 $ importance     : num [1:78, 1:2] 1040619 34174 148774 48116 235056
...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:78] "Age" "AntiarrhythmicsC" "AntiarrhythmicsDays"
"AntiarrhythmicsIIIC" ...
  .. ..$ : chr [1:2] "%IncMSE" "IncNodePurity"
 $ importanceSD   : atomic [1:78] 308517 9618 43424 11313 101015 ...
  ..- attr(*, ".Names")= chr [1:78] "Age" "AntiarrhythmicsC"
"AntiarrhythmicsDays" "AntiarrhythmicsIIIC" ...
 $ localImportance: num [1:78, 1:51368] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:78] "Age" "AntiarrhythmicsC" "AntiarrhythmicsDays"
"AntiarrhythmicsIIIC" ...
  .. ..$ : chr [1:51368] "1" "2" "3" "4" ...
 $ proximity      : symbol proximity
 $ ntree          : int 500
 $ mtry           : num 6
 $ forest         : atomic [1:10] c(525, 525, 525, 525, 525, 5
structure(c(-3, -3, -3, -3, H structure(c(2, 4, 6, 8, 10, H
structure(c(3, 5, 7, 9, 11, H ...
  ..- attr(*, ".Names")= chr [1:10] "ndbigtree" "nodestatus"
"leftDaughter" "rightDaughter" ...
 $ coefs          : symbol coefs
 $ y              : num [1:51368] 26697 28758 611 1035 12483 ...
 $ test           : symbol test
 $ inbag          : symbol inbag
 - attr(*, "class")= chr "randomForest"

I tried dump() in Splus then source() in R as well, but the source()
function returns error:

Error in attributes(.Data) <- c(attributes(.Data), attrib) : 
  attributes must be named

 
Thanks,
Jimmy

-----Original Message-----
From: Liaw, Andy [mailto:andy_liaw at merck.com] 
Sent: Tuesday, August 09, 2011 12:12 PM
To: Zhiming Ni; r-help at r-project.org
Subject: RE: convert a splus randomforest object to R

You really need to follow the suggestions in the posting guide to get
the best help from this list.  

Which versions of randomForest are you using in S-PLUS and R?  Which
version of R are you using?  When you restore the object into R, what
does str(object) say?  Have you also tried dump()/source() as the R Data
Import/Export manual suggests?

Andy
Notice:  This e-mail message, together with any attachme...{{dropped:24}}