Write a R function that uses the Olympic database to print out the names
# of all athletes that won medals of choice in an Olympic sport. The printout
# provides the name of the athletes, the year of the Olympics, the medal achieved
# the sport and the country of their origin.
#
# You are limited to using conditional and control flow methods (if statements, loops,
# logical and relational operators). You cannot use the tidyverse technique in this task.
# Turn your algorithm into a function so that we can use it for other sports and
# any of three medals (Gold, Silver or Bronze). The function should have three or less
# arguments.
# Hints:
# 1) Cut the data frame down in size (less rows) to practice on a smaller
# set of inputs;
# 2) Create a script that works for say (sport = "Cycling" and medal = "Gold");
# 3) Once it works, wrap the script into a function syntax;
# 4) Make the sport and medal functional arguments;
# 5) You could import the data frame within the function;
# 6) Within the function, consider using the "which()" function that results in
# an index for selecting rows (that is, the sport and medal of choice);
# 7) Perhaps use a "for loop" that will iterate through the index. This can help
# to identify other elements in the same row (i.e., name of athlete, year, country);
# 8) Use the print(paste()) combination to print out your results.
# 9) The function should work when the data and the script are in the same folder;
# 10) Of course, there are many ways that will work to create this output. Please don't
# be shy to use your own creativity!
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
30 | 31 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 1 | 2 | 3 |
Get Free Quote!
377 Experts Online