knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(recurpkg)
The package is designed for recursive sequence calculation. The formular for the recursive sequence is as following:
$X_n$ = $X_{n-1}$ + |$X_{n-2} - X_{n-3}$|/2
That is, element N is the sum of element N−1 and the absolute value of the difference between elements N−2 and N−3 divided by two where each element is a number. For example, if we let $x_1$=3, $x_2$=1, and $x_3$=10, then $x_4$ is
$x_4$ = 10 + |1 - 3|/2 = 11
Some examples about the package use
recur_vec(x = c(2, 4, 3), n = 3)
recur_vec(x = c(2, 4, 3), n = 4)
recur_vec(x = c(2, 4, 3), n = 5)
For the recursive dataset calculation, the users are expected to submit a data frame with four columns:
-The first three columns are the values of the three numeric to be input to the recursive sequence function defined above and the fourth column is the positive integer n for the sequence to be generated.
-This function should return a line plot of the output values for the different values of n.
examlpe about the dataset function use
my_data <- tibble::tribble( ~x, ~y, ~z, ~n, 2,4,3,3, 2,4,3,5, 2,4,3,7, 2,4,3,10, 2,4,3,15, 2,4,3,20, 2,4,3,25 ) recur_dataset(my_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.