Hi,

I havenĀ“t much experience on writing functions and would like to modify the simple tbrm() function from package dplR in order to save the weights that it produces. I have tried using the superassignment operator as explained in the R intro, but is this the right way to save a variable within a function? This is my code

mytukey <- function (x, C = 9)
{
    wt = rep(0, length(x))
    x.med = median(x)
    S.star = median(abs(x - x.med))
    w0 = (x - x.med)/(C * S.star + 1e-06)
    lt0.flag = abs(w0) <= 1
    wt[lt0.flag] = ((1 - w0^2)^2)[lt0.flag]
    t.bi.m = sum(wt * x)/sum(wt)
    myweights<<-wt  # this is my added line
    t.bi.m

}


Thanks,

D.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to