powered by
Builds an interactive Plotly animation of Riemann sums approximating the area under a function on a closed interval.
riemann_rectangles2d( f, a, b, n_vals = NULL, method = c("midpoint", "left", "right"), n_curve = 400L, frame_ms = 900L, transition_ms = 0L, title = NULL, show_sum = TRUE, y0 = 0 )
A plotly object (htmlwidget) with animation frames.
Function. A real-valued function. It must accept a numeric vector and return a numeric vector of the same length.
Numeric scalar. Left endpoint.
Numeric scalar. Right endpoint. Must satisfy b > a.
Integer vector. Values of the number of subintervals used as animation frames. If NULL, a default increasing sequence is used.
Character. Rule used for rectangle heights: "midpoint" (default), "left", or "right".
Integer. Number of points used to draw the base curve.
Integer. Frame duration in milliseconds.
Integer. Transition duration in milliseconds.
Character. Plot title. If NULL, a default title is used.
Logical. If TRUE, show n and the value of the Riemann sum in hover text.
Numeric scalar. Baseline for rectangles (default 0).
# \donttest{ library(plotly) f <- function(x) x^2 riemann_rectangles2d(f, 0, 1) # }
Run the code above in your browser using DataLab