R/knapsack_objects.R

Defines functions knapsack_data

Documented in knapsack_data

#' Knapsack data
#' A funtion that simulates data to the Knapsack problem.
#' 
#' 
#' @param n size of the data frame.
#' @param seed set seed of the simulated data.
#' 
#' @return A dataframe with 2 variables and n rows. 
#' @export


knapsack_data<-function(n=2000,seed=42){
  set.seed(seed)
  n <- n
  knapsack_objects <-data.frame(
      w=sample(1:4000, size = n, replace = TRUE),
      v=stats::runif(n = n,0,10000)
    )
  return(knapsack_objects)
}
harjew/lab6G3 documentation built on Nov. 4, 2019, 1:28 p.m.