Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Episode 7 (control flow), Challenge 1 #603

Open
mstrimas opened this issue Jan 12, 2020 · 0 comments
Open

Episode 7 (control flow), Challenge 1 #603

mstrimas opened this issue Jan 12, 2020 · 0 comments

Comments

@mstrimas
Copy link
Contributor

@mstrimas mstrimas commented Jan 12, 2020

This challenge asks student to print an informative message if there are any records in gapminder for the year 2002. Two solutions are provided, one using any(gapminder$year == 2002) (note any() isn't introduced until later in that episode) and one much more complicated one involving counting the number of rows for the year 2002. It seems to me the only reasonable way to do this is with %in%, which is much simpler and uses a function that was introduced in the previous episode. I propose the solution should be:

if (2002 %in% gapminder$year) {
  print("Record(s) for the year 2002 found.")
}

I could see an argument for keeping the approach using any() as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.