Hi,
   
  I must be missing something here...Essentially, a short piece of code works 
if it's standalone, but doesn't work if it's divided into two functions. 
   
  The code that works is:
   
   ################### WORKS ###############
     
library(pamr)
     
set.seed(120)
x <- matrix(rnorm(1000*20),ncol=20)
y <- sample(c(1:4),size=20,replace=TRUE)
mydata <- list(x=x,y=y)
mytrain <-   pamr.train(mydata)
new.scales <- pamr.adaptthresh(mytrain,ntries = 1)
   
  ########################################
   
  But if I split the lines into two functions, then I get an error message that 
reads :
  'Error in pamr.train(data = myd2, threshold = threshold, threshold.scale = 
all.scales[i+ : object "myd2" not found.'
   
  The code that doesn't work is:
   
  
################### DOESN'T WORK ############
library(pamr)
     
domat <- function(myd){
      myd2 <- myd
    mytrain <-   pamr.train(myd2)
    new.scales <- pamr.adaptthresh(mytrain)
  }
  dom <- function(){
     set.seed(120)
     x <- matrix(rnorm(1000*20),ncol=20)
     y <- sample(c(1:4),size=20,replace=TRUE)
     myda <- list(x=x,y=y)
     domat(myda)
}
  dom()
   
  #########################################
   
  Did I do something really goofy? How can I find out what's happening? 
   
  many thanks.
   
   

                
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to