Question: The dist() function is an R built-in function that takes a matrix (or a data frame) and returns the distance between the individuals (rows) of
The dist() function is an R built-in function that takes a matrix (or a data frame) and returns the distance between the individuals (rows) of the matrix.
- Without using for loops or apply functions, create a matrix containing 10 rows and 5 columns. The elements of the matrix are integer numbers randomly selected from 1 to 10 (1 point).
- Apply the dist() function to the above matrix and assign the output to an object called m_dist. Assume that you want to print the distances between the first 6 units. What does head(m_dist) return? What is the class of m_dist? What output would you expect if m_dist was a matrix? Write a code to print the first 6 rows of m_dist. (2 points)
can you provide R code? thank you.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
