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

Discussion: Functional programming (maps) material in R? #77

Closed
lwjohnst86 opened this issue May 27, 2019 · 3 comments
Closed

Discussion: Functional programming (maps) material in R? #77

lwjohnst86 opened this issue May 27, 2019 · 3 comments
Labels
discussion discussion before a proposal

Comments

@lwjohnst86
Copy link
Contributor

I actually think that, while mapping as a topic is difficult, the implementation (at least in R) is relatively straight forward using purrr. Plus by at least showing it, the learners can see that this tool exists. And then they won't be tempted to using for loops (not good in R).
Originally posted by @lwjohnst86 in https://github.com/merely-useful/merely-useful.github.io/pull/63/files

Using "mapping" (aka functional programming) in R is fairly common, given that R strength is not in iteration but in vectorization. I think some section on it would be useful mainly as a deterred to using loops and to show that there are saner ways of iterating rather than using the *apply family of R functions. I don't know what the equivalent is for Python.

Should we also include material on map in the novice R material?

@lwjohnst86 lwjohnst86 added discussion discussion before a proposal Novice R labels May 27, 2019
@cwickham
Copy link
Contributor

I like this idea! Being able to solve a problem on one object and then easily apply it to many is one of the huge powers of coding for data analysis that I'd like novices to be exposed to.

A couple of questions:

  • How much does this necessitate a detour into understanding lists? Lists are a fundamental data type for people to master in R, so I see the value in covering them, but I've also been guilty of ending up spending so much time of this part, that the actual iteration part gets swamped.

  • Do we go anywhere near list columns? I use them all the time, in fact most of my map() uses are inside tibbles, but if you are still mastering mutate() adding map() to the mix can be confusing.

@cwickham
Copy link
Contributor

Another thought:

At some point we might talk about element-wise operations, and that many R functions work this way be default, i.e. vectorization. We could then introduce map() as a way of handling functions that don't work this way.

@lwjohnst86
Copy link
Contributor Author

We'll add these as appropriate in the R lessons. Passed in 2019-06-11 meeting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion discussion before a proposal
Projects
None yet
Development

No branches or pull requests

2 participants