swcarpentry / r-novice-gapminder

R for Reproducible Scientific Analysis
http://swcarpentry.github.io/r-novice-gapminder/
Other
164 stars 538 forks source link

"Seeking Help" challenge 2 answer & example misleading #256

Closed delocalizer closed 7 years ago

delocalizer commented 7 years ago

The explanation of the difference between sep and collapse is if not wrong, then pretty misleading - the actual difference between these is that sep string separates terms, and collapse joins results after concatenation. The example given only works because the arguments supplied are of length 1, which is a sort of degenerate case for paste. A clearer example would be:

> paste(1:2, 3:4)
[1] "1 3" "2 4"
> paste(1:2, 3:4, sep = ',')
[1] "1,3" "2,4"
> paste(1:2, 3:4, sep = ',', collapse = '|')
[1] "1,3|2,4"

but this presumes a knowledge of vectors that the lesson hasn't yet reached at this point. So perhaps choose a different function than paste to use as an example?

naupaka commented 7 years ago

@delocalizer thanks for the comment. Which episode and line number is the current explanation on?

delocalizer commented 7 years ago

Hi @naupaka, it is episode 3, in challenge 2: https://github.com/swcarpentry/r-novice-gapminder/blame/gh-pages/_episodes/03-seeking-help.md#L177

naupaka commented 7 years ago

@delocalizer I agree the current explanation is not so helpful. I also agree your example is clearer, but I think you're right about the problem about relying on a solid understanding of vectorized operations.

What about:

> paste(c("a","b"), "c")
[1] "a c" "b c"
> paste(c("a","b"), "c", sep = ",")
[1] "a,c" "b,c"
> paste(c("a","b"), "c", sep = ",", collapse = "|")
[1] "a,c|b,c"
delocalizer commented 7 years ago

Yes, that looks good to me

naupaka commented 7 years ago

@delocalizer want to submit a PR with this change?

delocalizer commented 7 years ago

sure thing


From: Naupaka Zimmerman notifications@github.com Sent: Thursday, 27 April 2017 12:12 AM To: swcarpentry/r-novice-gapminder Cc: Conrad; Mention Subject: Re: [swcarpentry/r-novice-gapminder] "Seeking Help" challenge 2 answer & example misleading (#256)

@delocalizerhttps://github.com/delocalizer want to submit a PR with this change?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/swcarpentry/r-novice-gapminder/issues/256#issuecomment-297421093, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAx6kc4uqBqEcnRR2pw_4o0_3CZ7cI_rks5rz1C2gaJpZM4MvQdR.

naupaka commented 7 years ago

Closed by #262