15.1 Exercise 9: For loop

Create the script “exercise9.R” and save it to the “Rcourse/Module2” directory: you will save all the commands of exercise 9 in that script.
Remember you can comment the code using #.

correction

1- Write a for loop that iterates over 2 to 10 and prints the square root of each number (function sqrt()).

correction

2- Write a for loop that iterates over 5 to 15 and prints a vector of 2 elements containing each number and its square root

correction

3- Create the following matrix

  • Write a for loop that iterates over each row of mat1 and prints the median value of each row.

correction