Question: R # The function below gives misleading outputs random.sum
R
# The function below gives misleading outputs
random.sum <- function(n) { # sum of n random numbers x[1:n] <- ceiling(10*runif(n)) cat("x:", x[1:n], " ") return(sum(x)) }
x <- rep(100, 10)
# For example, try
show(random.sum(10)) show(random.sum(5))
# Explain what is going wrong and fix this function so that it does what it says it does. Note which lines you fixed and why they would not work.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
