[R] modifying tbrm function

From: DAVID ARTETA GARCIA <darteta001_at_ikasle.ehu.es>
Date: Fri, 06 Jun 2008 10:24:46 +0200


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




R-help_at_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. Received on Fri 06 Jun 2008 - 08:36:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 06 Jun 2008 - 09:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive