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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!