Suppose you're asked to create a vector of numbers in R and calculate the mean and median. How would you do it?

  • Use the array() function to create a vector and then use the mean() and median() functions
  • Use the c() function to create a vector and then use the mean() and median() functions
  • Use the list() function to create a vector and then use the mean() and median() functions
  • Use the vector() function to create a vector and then use the mean() and median() functions
In R, we create a vector of numbers using the c() function, and then calculate the mean and median using the mean() and median() functions. For example, x <- c(1, 2, 3, 4, 5); mean(x); median(x) would create a vector and compute the mean and median of its elements.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *