2017年5月7日星期日

Create an empty list and flatten the list

x<-c(2.3,0.3,5.2,3.1,1.1,0.9,2.0,0.7,1.4,0.3)
y<-c(0.8,2.8,4.0,2.4,1.2,0.0,6.2,1.5,28.8,0.7)

L<-vector("list",10)

for(i in 1:10){

L[[i]]<-y[i]-x #key is [[]] operator here
}

d<-unlist(L)
median(d)  # This is Hodges-Lehmann estimator