#Examples for rank.d2e.Te
n<-20
set.seed(1)
dat<-runifTe(n)$gen.points
dec.dist<-rank.d2e.Te(dat)
dec.dist
dec.dist.rank<-dec.dist[[2]] #the rank of distances to the edges in decreasing order
dec.dist.rank
dist<-dec.dist[[1]] #distances to the edges of the std eq. triangle
dist
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.0,.01),ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(dat,pch=".")
text(dat,labels = factor(dec.dist.rank) )
inc.dist<-rank.d2e.Te(dat,dec = FALSE)
inc.dist
inc.dist.rank<-inc.dist[[2]] #the rank of distances to the edges in increasing order
inc.dist.rank
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist
plot(A,pch=".",xlab="",ylab="",xlim=Xlim,ylim=Ylim)
polygon(Te)
points(dat,pch=".",xlab="",ylab="", main="",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
text(dat,labels = factor(inc.dist.rank) )
rank.d2e.Te(rbind(dat,dat))
dat.fr<-data.frame(a=dat)
rank.d2e.Te(dat.fr)
#Examples for order.d2e.Te
n<-20
set.seed(1)
dat<-runifTe(n)$gen.points #try also dat<-cbind(runif(n),runif(n))
dec.dist<-order.d2e.Te(dat)
dec.dist
dec.dist.order<-dec.dist[[2]] #the order of distances to the edges in decreasing order
dec.dist.order
dist<-dec.dist[[1]] #distances to the edges of the std eq. triangle
dist
dist[dec.dist.order] #distances in decreasing order
dat[dec.dist.order,] #data in decreasing order
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.01,.01),ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(dat,pch=".")
text(dat[dec.dist.order,],labels = factor(1:n) )
inc.dist<-order.d2e.Te(dat,dec = FALSE)
inc.dist
inc.dist.order<-inc.dist[[2]] #the order of distances to the edges in increasing order
inc.dist.order
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist
dist[inc.dist.order] #distances in increasing order
plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
points(dat,pch=".")
text(dat[inc.dist.order,],labels = factor(1:n) )
order.d2e.Te(rbind(dat,dat))
dat.fr<-data.frame(a=dat)
order.d2e.Te(dat.fr)
Run the code above in your browser using DataLab