I read the following codes in a book. Not quite sure of the 'names<-' part in last line.
Could someone provide some reference for this? Is this related to the functions forms mentioned in section 6.8 of https://adv-r.hadley.nz/functions.html ? Or they define the attributes in some way? Thanks.
bs.quantile <- function(v, p=c(0, 0.25, 0.5, 0.75, 1))
{
b <- 1-p
k <- floor((ps <- p*length(v))+b)
beta <- ps+b-k
'names<-'((1-beta)*(v <- sort(v))[k]+beta*(ifelse(k<length(v), v[k+1], v[k])), p)
}
There are several other places where the author use this approach.
‘class<-‘(tree, "dectree.frac")
‘class<-‘(list(prior=cc/sum(cc),cond=sapply(avc,
function(avc1) t(apply(avc1, 1, "/", colSums(avc1))))),"nbc")
}