R/recurseq2.R

Defines functions recurseq2

Documented in recurseq2

#' Plot recursive sequence output
#'
#' This takes a data frame with four columns (The first three columns are the values
#' of the three numerics to be input to function 1 and the fourth column is the
#' positive integer n for the sequence to be generated). The function will return a
#' line plot of the output values for the different values of n.
#' @param x data frame
#'
#' @return line plot
#' @export recurseq2
#' @importFrom ggplot2 ggplot aes geom_line
#'
#' @examples my_data <- tibble::tribble(
#' ~x, ~y, ~z, ~n,
#' 2,4,3,3,
#' 2,4,3,4,
#' 2,4,3,5,
#' 2,4,3,6,
#' 2,4,3,7,
#' 2,4,3,8,
#' 2,4,3,9,
#' 2,4,3,10,
#' 2,4,3,12)
#' recurseq2(my_data)
recurseq2 <- function(x){
  calcn2_v <- vector("numeric", length = nrow(x))
  for(i in seq(calcn2_v)){
    calcn2_v[i] <- recurseq1(c(x$x[i],  x$y[i], x$z[i]), x$n[i])
  }
  output <- calcn2_v
  n <- x$n
  data.frame(output, n) %>%
    ggplot2::ggplot() +
    ggplot2::geom_line(ggplot2::aes(n, output))
}
STAT-413-613-21S/hw04paevans872 documentation built on Feb. 28, 2021, 12:12 a.m.