interval.indices.set {pcds} | R Documentation |
Indices of the intervals where the 1D point(s) reside
Description
Returns the indices of intervals for all the points in 1D data set,
Xp
, as a vector.
Intervals are based on Yp
and left end interval is labeled as 1,
the next interval as 2, and so on.
If there are duplicates of Yp
points,
only one point is retained for each duplicate value,
and a warning message is printed.
Usage
interval.indices.set(Xp, Yp)
Arguments
Xp |
A set of 1D points for which the indices of intervals are to be determined. |
Yp |
A set of 1D points from which intervals are constructed. |
Value
The vector
of indices of the intervals in which points in the 1D data set, Xp
, reside
Author(s)
Elvan Ceyhan
Examples
a<-0; b<-10; int<-c(a,b)
#nx is number of X points (target) and ny is number of Y points (nontarget)
nx<-15; ny<-4; #try also nx<-40; ny<-10 or nx<-1000; ny<-10;
set.seed(1)
xf<-(int[2]-int[1])*.1
Xp<-runif(nx,a-xf,b+xf)
Yp<-runif(ny,a,b) #try also Yp<-runif(ny,a+1,b-1)
ind<-interval.indices.set(Xp,Yp)
ind
jit<-.1
yjit<-runif(nx,-jit,jit)
Xlim<-range(a,b,Xp,Yp)
xd<-Xlim[2]-Xlim[1]
plot(cbind(a,0), xlab=" ", ylab=" ",xlim=Xlim+xd*c(-.05,.05),ylim=3*c(-jit,jit),pch=".")
abline(h=0)
points(Xp, yjit,pch=".",cex=3)
abline(v=Yp,lty=2)
text(Xp,yjit,labels=factor(ind))
[Package pcds version 0.1.8 Index]