Adjust the following R code so it removes the output circled in red.
Posted: Tue May 24, 2022 8:03 am
Adjust the following R code so it removes the output circled in
red.
***{r} set. seed (0) waiting_guests <- function(lambda, guests, hours) { # null vector vec vec <- c() # initialize values as in the code current_guests <- 0 remaining_guests <- 0 # while loop with condition hours != 0 while (hours != 0) { # update values current_guests <- remaining_guests + rpois (1, lambda) remaining_guests <- max( current_guests print (paste(current_guests, guests, 0) remaining_guests)) vec <-c(vec, remaining_guests) #update hours hours < hours-1; } # return the vector return (vec) } answer <- waiting_guests (3,4,8) print (answer) [1] "5 1" [1] "30" [1] "20" [1] "30" [1] "5 1" [1] "30" [1] "5 1" 11 "7 3" [1] 1 0 0 0 1 0 1 3
red.
***{r} set. seed (0) waiting_guests <- function(lambda, guests, hours) { # null vector vec vec <- c() # initialize values as in the code current_guests <- 0 remaining_guests <- 0 # while loop with condition hours != 0 while (hours != 0) { # update values current_guests <- remaining_guests + rpois (1, lambda) remaining_guests <- max( current_guests print (paste(current_guests, guests, 0) remaining_guests)) vec <-c(vec, remaining_guests) #update hours hours < hours-1; } # return the vector return (vec) } answer <- waiting_guests (3,4,8) print (answer) [1] "5 1" [1] "30" [1] "20" [1] "30" [1] "5 1" [1] "30" [1] "5 1" 11 "7 3" [1] 1 0 0 0 1 0 1 3