is.in.data {pcds} | R Documentation |
Check a point belong to a given data set
Description
returns TRUE
if the point p
of any dimension is inside the data set Xp
of the same dimension as p
;
otherwise returns FALSE
.
Usage
is.in.data(p, Xp)
Arguments
p |
A 2D point for which the function checks membership to the data set |
Xp |
A set of 2D points representing the set of data points. |
Value
TRUE
if p
belongs to the data set Xp
.
Author(s)
Elvan Ceyhan
Examples
n<-10
Xp<-cbind(runif(n),runif(n))
P<-Xp[7,]
is.in.data(P,Xp)
is.in.data(P,Xp[7,])
P<-Xp[7,]+10^(-7)
is.in.data(P,Xp)
P<-Xp[7,]+10^(-9)
is.in.data(P,Xp)
is.in.data(P,P)
is.in.data(c(2,2),c(2,2))
#for 1D data
n<-10
Xp<-runif(n)
P<-Xp[7]
is.in.data(P,Xp[7]) #this works because both entries are treated as 1D vectors but
#is.in.data(P,Xp) does not work since entries are treated as vectors of different dimensions
Xp<-as.matrix(Xp)
is.in.data(P,Xp)
#this works, because P is a 1D point, and Xp is treated as a set of 10 1D points
P<-Xp[7]+10^(-7)
is.in.data(P,Xp)
P<-Xp[7]+10^(-9)
is.in.data(P,Xp)
is.in.data(P,P)
#for 3D data
n<-10
Xp<-cbind(runif(n),runif(n),runif(n))
P<-Xp[7,]
is.in.data(P,Xp)
is.in.data(P,Xp[7,])
P<-Xp[7,]+10^(-7)
is.in.data(P,Xp)
P<-Xp[7,]+10^(-9)
is.in.data(P,Xp)
is.in.data(P,P)
n<-10
Xp<-cbind(runif(n),runif(n))
P<-Xp[7,]
is.in.data(P,Xp)
[Package pcds version 0.1.8 Index]