count2d: Count the number of observation in 2d space.

View source: R/count2d_function.R

count2dR Documentation

Count the number of observation in 2d space.

Description

This function will count the number of observations in 2d space with the ability to set the x and y begin, end, and width(len) values. Provide either begin, end, and len, or xbegin, xend, xlen, ybegin, yend, and ylen.

Usage

count2d(
  x,
  y,
  begin = NA,
  end = NA,
  len = NA,
  xbegin = NA,
  xend = NA,
  xlen = NA,
  ybegin = NA,
  yend = NA,
  ylen = NA
)

Arguments

x

A numeric vector with the x positions.

y

A numeric vector with the y positions.

begin

A numeric value to begin the x and y bins.

end

A numeric value to end the x and y bins.

len

A numeric value to use and the x and y bin width.

xbegin

A numeric value to begin the x bins.

xend

A numeric value to end the x bins.

xlen

A numeric value to use and the x bin width.

ybegin

A numeric value to begin the y bins.

yend

A numeric value to end the y bins.

ylen

A numeric value to use and the y bin width.

Value

A dataframe with the x and y bin number, centers, range, and the count.

Examples



### Create Test data
x1 <- runif(1000,0,10)
y1 <- runif(1000,0,10)
data1 <- data.frame(x=x1,y=y1)

### Count the number of observations from 0 to 10 by 1.
dfout <- count2d(x=data1$x,y=data1$y,begin=0,end=10,len=1)
# or
dfout <- count2d(x=data1$x,y=data1$y,
                 xbegin=0,xend=10,xlen=1,
                 ybegin=0,yend=10,ylen=1)




Louismp1223/LMP3 documentation built on June 29, 2022, 5:11 p.m.