getBoxplot: Get dataframe to boxplot

View source: R/manageGrid.R

getBoxplotR Documentation

Get dataframe to boxplot

Description

Given a Grid1d class object and a matrix or dataframe of points, it returns a dataframe with original points and a supplementary column which groups the y points that fall in the same vertical strip.

Usage

getBoxplot(grid, points)

Arguments

grid

Grid1d object, made with makeGrid1d function

points

2d matrix or dataframe of points

Value

A dataframe with three columns: xbp (x relative to boxplot), x and y (original points)

Examples

# 1. Generate random points on a plane
df_points <- data.frame(
  x = c(rnorm(n = 50000, mean = -2), rnorm(n = 50000, mean = 2)),
  y = c(rnorm(n = 50000, mean = 1), rnorm(n = 50000, mean = -1))
)

# 2. Define a grid that contains all the points generated along x
stripes <- makeGrid1d(
  xmin = floor(min(df_points$x)), xmax = ceiling(max(df_points$x)), xcell = 50
)

# 3. Obtain boxplot dataframe
df_boxplot <- getBoxplot(stripes, df_points)

head(df_boxplot)


Leonardo-Bo/rgrids documentation built on July 27, 2024, 2:19 a.m.