I’m pleased to announce that a rewrite of my first chapter of “Modeling Data With Functional Programming In R” is available in draft format. Most of the feedback of the previous version centered around accessibility and practicality of the material. In response, this first chapter is dedicated to discussing the functional programming paradigm and the key role of the function. It then progresses into talking about the relationships between mathematical notation we take for granted and functional programming syntax. The chapter concludes by introducing the lambda calculus using Church numerals to illustrate key concepts. This version includes many examples using the iris dataset, so the examples are all easily reproducible.

Any and all feedback is greatly appreciated.

Rowe. Modeling Data With Functional Programming In R, Chapter 1

0.000000
0.000000

### Like this:

Like Loading...

*Related*

Sebastian Warnholz

said:Hi, I enjoyed reading the first chapter of your book. Looking forward to read the next. What I would be interested in are exercises for each chapter. It is hard to keep track of the formal elements of the lambda calculus just by reading, although the comparisons between R code and lambda.r expressions are great already. Also I would be interested in using the lambda.r package. Do you have experience if and how it cooperates with roxygen2 for documentation? Are there recommendations if functions written in lambda.r should be documented differently in packages? I am wondering, since function dispatching is usually achieved using S3 or S4 and both result in several entries in the documentation for the generic function and methods.

Ok, enough questions for today. Thanks for the package and book!

Brian Lee Yung Rowe

said:Sebastian, Thanks for the kind words. I am planning on adding more exercises but probably won’t get to it until near the end of the process.

In terms of using lambda.r for package development, take a look at lambda.tools, which uses lambda.r and ROxygen2. Basically the usage sections have to be entered manually via a block

`@section Usage:`

. Take a look and let me know if you have any questions.ubergooroo

said:Page 7…

When calling the function, we need to decide what the na.fn function

should do. A ﬁrst approach is to create a function that computes the mean

of the non-NA values. But ﬁrst we need to modify the iris dataset by adding

some NAs. We’ll create a new data.frame instead of modifying iris directly.

I think it would be nice here to point out that one way to handle the NA values is to impute data to replace the NA’s by computing the mean of the non-NA values.

I didn’t get what you were trying to do until I looked at this code closely ifelse(is.na(z), na.fn(z), z).

Brian Lee Yung Rowe

said:Thanks, this is a good point. I’ll definitely add some more exposition to make it clearer.