--3-Functional programming
df <- data.frame(
a = rnorm(10),
b = rnorm(10),
c = rnorm(10),
d = rnorm(10)
)
#We've provided some code to get you started.
#Fill in the body of the for loop to calculate the median of each column and
#store the results in output.
# Initialize output vector
output <- vector("double", ncol(df))
# Fill in the body of the for loop
for (i in seq_along(df)) {
output[[i]] <- median(df[[i]])
}
# View the result
outputLast updated