Selling my first book

Thursday evening last week I got an email from apress.com about my Functional Programming in R book and whether I would be interested in finding a publisher for it. It is already published on leanpub, Amazon and iBooks, but it has never seen a proper editor, and I would love to see it in print, so I wrote back that I would love to hear more.

I got a little more info Friday and was asked for a PDF of the book. I sent that but also the PDF for my Data Science in R book, mentioning that this book is longer and selling better.

Later Friday evening I got an offer for the data science book that I accepted. They are still interested in the functional programming book, but I had some suggestions for how it could be expanded and such, so they want to think a little more about that. The thinking time also gives me some time to judge the experience with editing the first book.

Because I’m selling Data Science in R, it will no longer be online. Not until Apress has made an ebook, at least. I’ve pulled it down from Amazon already, I’m trying to figure out how to remove it from iBooks now, and I will remove it from Leanpub afterwards. If anyone knows how to pull down a book from iBooks, please let me know.

I wrote that I would pull the book offline on twitter and Facebook yesterday, and since I’ve sold a lot of copies. I guess to people who want the book before it goes offline. Thanks for that, guys.

Rplot.png

It will still be available there a few hours more, but it is going down tonight.

Functional Programming will stay online until I figure out what will happen with it, and of course so will Object-oriented Programming in R, which I’m still working on.

I haven’t written on it the last two weeks. I’ve had some other things to work on and I’m a little stuck trying to think of a good example of where you would use refinement of interfaces, but I hope to have the next chapter finished in a week or so.

New writing workflow

I wrote Functional programming in R using Ulysses and have used Ulysses to write the first part of Object oriented programming in R as well. It is a very nice editor, and I am definitely using it in the future for other writing projects, but for the workflow with these books it doesn’t really work for me anymore.

The way I write the books is this: I write in R Markdown that I then need to run through ‘knitr’ to get the R code executed, this generates Markdown files that I then process using ‘pandoc’.

To get the full set of features in Ulysses, I have to use their internal file format, which means I have to export files ever time I need to compile the text. It is not a major hassle, but it is a little annoying.

It is especially annoying with Object-oriented programming in R where the second chapter has some performance measurement code that takes a while to run. I don’t want to run that every time I compile the book, so having a make file that makes sure I only compile and run the R code when necessary is the way to go, but either I have to be careful to export chapters in separate files (and remember to do that every time I change the text), or I have to just edit the raw Markdown files and not bother with the internal file format.

I have decided on the latter. I can’t use the more advanced features then, so I will edit with iA Writer instead, I think, just to give that a good try for comparison with Ulysses. I already use iA Writer for most Markdown editing, but I haven’t tried using it for a book yet. I will miss Ulysses’ sheets — they make it easy to move sections about — but I am sure I can manage without them.

With iA writer I can’t use the more advanced features like embedded files and such outside of iCloud, as far as I can see, but that wouldn’t really work well with the book compilation framework anyway. Embedding figures, for example, doesn’t really work for me because I need different figures when compiling to PDF and when making EPub. So I have to have the figures external to the text in any case.

You can see my current setup at github. I just have a Makefile for processing the files. First I send the R Markdown through a pre-processor — this is how I can have different code run depending on whether I’m making a PDF or an ebook — and after that through knitr and finally through pandoc.

Experimenting with GitHub for exercises

I have used GitHub to set and correct exercises in my Data Science class the last two weeks. More specifically, I used GitHub Classroom.

I wouldn’t recommend that.

What I find works well is using GitHub to describe the exercises — the README file that gets rendered nicely on the repository front page is good for that — and you can very easily provide template code and data.

I definitely should have given my students more information about how to clone repositories and how to push changes back, but lesson learned, so I will do better next time.

Commenting on changes in the students’ repositories is also very easy as is following up on comments and checking changes made to fix problems.

What does not work well is that the Classroom just give each student a repository that is completely disconnected from the template I made. The way it works is that for each student and each assignment you get a new repository where a template repository is used to initialise it. It does that, as far as I can see, by just cloning in the original repository and not by forking it.

In principle there is nothing wrong with that, but it gets a little annoying when correcting exercises. I can go in and see the change log on each project, but I don’t get informed when the students think they are done — as I would if it required a pull request — and what is worse is that I don’t get a diff from my original template to the current state of the students’ solutions. (I can get that with a little work, but if I just want to go in and comment on commits I get the changes in bites matching the commits, I don’t see the combined changes).

So the plan now for the coming weeks is to use forks and pull requests instead. I have high hopes for that.

I still need to figure out a good way of signalling that a pull request is accepted as a hand-in without merging it into my repository. I can’t merge all students’ pull requests, but ideally that would be the way to indicate that a request is accepted.

This is less than ideal…

Yeah, I knew that writing would never give me a decent hourly salary, but this is a little depressing…

Oh well, I will probably manage to get the $61 back, but I will have to reconsider my Grammarly subscription when it runs out and I probably have to think carefully about putting up a new book (I was planning to start one on meta-programming and one on functional data structures, not sure about the order, once I’m done with OOP in R).

Progress is a little slow on Object-oriented programming in R. I thought I would get inspired by #NaNoWriMo and pick up speed (I’m not planning on actually writing a novel, but I could write faster on OOP in R). That hasn’t really happened.

I have written a lot the last couple of weeks, but it has been on papers or teaching material and not my book, so when I finish work my brain is just not up to writing much more.

Still, while it may be going along slowly, it is moving along.