Learn R Programming

pcds (version 0.1.2)

is.in.data: Check a point belong to a given data set

Description

returns TRUE if the point p of any dimension is inside the data set Dt of the same dimension as p; otherwise returns FALSE.

Usage

is.in.data(p, Dt)

Arguments

p

A 2D point for which the function checks membership to the data set Dt.

Dt

A set of 2D points representing the set of data points.

Value

TRUE if p belongs to the data set Dt.

Examples

Run this code
# NOT RUN {
n<-10
dat<-cbind(runif(n),runif(n))

P<-dat[7,]
is.in.data(P,dat)
is.in.data(P,dat[7,])

P<-dat[7,]+10^(-7)
is.in.data(P,dat)

P<-dat[7,]+10^(-9)
is.in.data(P,dat)

is.in.data(P,P)

is.in.data(c(2,2),c(2,2))

#for 1D data
n<-10
dat<-runif(n)

P<-dat[7]
is.in.data(P,dat[7])  #this works because both entries are treated as 1D vectors but
#is.in.data(P,dat) does not work since entries are treated as vectors of different dimensions

dat<-as.matrix(dat)
is.in.data(P,dat)
#this works, because P is a 1D point, and dat is treated as a set of 10 1D points

P<-dat[7]+10^(-7)
is.in.data(P,dat)

P<-dat[7]+10^(-9)
is.in.data(P,dat)

is.in.data(P,P)

#for 3D data
n<-10
dat<-cbind(runif(n),runif(n),runif(n))

P<-dat[7,]
is.in.data(P,dat)
is.in.data(P,dat[7,])

P<-dat[7,]+10^(-7)
is.in.data(P,dat)

P<-dat[7,]+10^(-9)
is.in.data(P,dat)

is.in.data(P,P)

n<-10
dat<-cbind(runif(n),runif(n))
P<-dat[7,]
is.in.data(P,dat)

dat.fr<-data.frame(a=dat)
is.in.data(P,dat.fr)

# }

Run the code above in your browser using DataLab