mauede at alice.it
2009-Apr-01 15:34 UTC
[R] Still confused about R method of data exchanging between caller and called function
First of all I'd like to thank all those who answered me back teaching me
different ways to get the calledfunction modify global data rather than its own.
I fixed that.
Now I have a similar pproblem. Whenever the caller passes a matrix to the called
function I thought the called function would make a copy of the passed array in
its own memory frame, modify its own copy, but be able to pass back the results
to the caller as follows ... but I am mistaken (I find all "NA" on the
second call ... how caome ?
"ford" <- function(X,N,Nfour,Kfour,LevMin,LevMax) {
............................................................
Y <- X
Nord <- Kord
if(Nord == 2){
cat("\n call HAAR \n")
Y <- Haar(Y,Nfour,1)
}else{
cat("\n call pwtset \n")
pwtset(Nord)
cat("\n call wt1 \n")
Y <- wt1(Y,Nfour,1)
cat("\n function 'ford' Y = ",Y,"\n")
}
#####################################################
"wt1" <- function (a,n,isign){
cat("\n BEGIN 'wt1' \n")
cat("\n 'wt1': n = ",n,"\n")
cat("\n 'wt1': a = ",a,"\n")
if (n < 4){
cat("\n function 'wt1': WRONG INPUT SIGNAL LENGTH \n")
return()
}
if(isign >= 0){
nn <- n
while(nn >= 4){
cat("\n call pwt \n")
a <- pwt(a,nn,isign)
nn <- nn/2
}
.......................................
cat("\n END 'wt1' \n")
a #RETURN WAVELET COEFFICIENTS
}# ------------------------------------ end function "wt1"
--------------------------------
tutti i telefonini TIM!
[[alternative HTML version deleted]]