swcarpentry/bc — pull request #675 by jdblischak (2014-08-22 18:52:42+00:00)
Title: Translation of novice Python lesson 02 on functions to R

This PR continues the translation of the novice Python lessons that began back in March. See PR #639 for the first lesson and also directions on how to view these changes locally (the GitHub rendered version does not have the images loaded).

For context, here are links to the novice Python lesson being translated ([rendered][], [source][]).

[rendered]: http://software-carpentry.org/v5/novice/python/02-func.html
[source]: https://github.com/swcarpentry/bc/blob/master/novice/python/02-func.ipynb

Here are some of the main decisions I made that expect to be discussed:

+ Since string processing is more difficult in R compared to Python, I switched the exercises from indexing a string to indexing a vector.
+ I use the term stack frame in preference to environment. My thinking is that using the general terminology will help them understand any programming language they come across, and that they can learn more about the details of R and environments from other sources if they choose to become more advanced R programmers. For example, we have material on [environments and scoping rules][scope] for our intermediate R bootcamps.
+ Instead of performing mathematical operations, e.g. `mean`, `sd`, on an entire array of data, which requires converting the data frame to a matrix, I changed the lesson to always perform these sorts of operations on vectors. This removes the awkward discussion of how sometimes we use a data frame and sometimes a matrix. If others like this, I will edit the first lesson to also avoid needing a matrix.
+ I changed the indenting of function bodies from 4 spaces to 2. While arbitrary, this change is in agreement with the [Google R style guide][google], [Hadley's style guide][adv-r], and the default setting in RStudio.

[scope]: https://github.com/swcarpentry/bc/blob/master/intermediate/r/functions/03-scoping_rules.Rmd
[google]: https://google-styleguide.googlecode.com/svn/trunk/Rguide.xml
[adv-r]: http://r-pkgs.had.co.nz/style.html

Please let me know what you think of the translations! Thanks!