smooth: Smooth a condensed data frame.

Description Usage Arguments Examples

View source: R/smooth.r

Description

Smooth a condensed data frame.

Usage

1
2
smooth(x, h, var = summary_vars(x)[1], grid = NULL, type = "mean",
  factor = TRUE)

Arguments

x

a condensed summary

h

numeric vector of bandwidths, one for each grouping variable in x

var

variable to smooth

grid

a data frame with the grouping colums as x. In order for the factored version of smooth_nd to work, this grid must be a superset of x.

type

type of smoothing to use. Current options are "mean", a kernel weighted mean; "regression", a kernel weighted local regression; and "robust_regression", robust kernel weighted local regression in the style of loess. Unique prefixes are also acceptable.

factor

if TRUE compute the n-dimensional smooth by a sequence of 1d smoothes. For type = "mean" the results are always the same grid values are uncorrelated (e.g. the grid is complete at every location); and is very approximate for type = "robust".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x <- runif(1e5)
xsum <- condense(bin(x, 1 / 100))
xsmu1 <- smooth(xsum, 5 / 100)
xsmu2 <- smooth(xsum, 5 / 100, factor = FALSE)

# More challenging distribution
x <- rchallenge(1e4)
xsum <- condense(bin(x, 0.1))
xsmu <- smooth(xsum, 1)

plot(xsum$x, xsum$.count, type = "l")
lines(xsmu$x, xsmu$.count, col = "red")

xsmu2 <- smooth(xsum, 1, type = "regress")
plot(xsmu$x, xsmu$.count, type = "l", xlim = c(0, 50))
lines(xsmu2$x, xsmu2$.count, col = "red")
# Note difference in tails

hadley/bigvis documentation built on May 17, 2019, 9:45 a.m.