tlverse/origami

clearer code styling in wrappers (via JOSS)

nhejazi opened this issue · 1 comments

This should be good to go as far as JOSS is concerned, but I have a few additional comments that I hope you'll find helpful. The package looks very useful, but the examples don't quite feel right to me. I'd sort of compare it to the idea of something being "pythonic" in python. As you probably know, there are basically two distinct styles in R, base and tidy. This package isn't in the tidy philosophy (which is fine), but it doesn't feel quite right with base either. If we take your linear models example, you could swap out the use of strings for formulas, so the first few lines might look like:

  f <- formula(reg_form)
  mf <- model.frame(f, data=data)
  out_var_ind <- 1

  # split up data into training and validation sets
  train_data <- training(mf)
  valid_data <- validation(mf)

This way you could actually automate all of this for the user, and then the cv_lm() function would only need to do the fitting. Then in cross_validate(), you would pass reg_form=mpg ~ .. You could also play the game of attaching the data to the folds object (sort of like how lm() itself does) to simplify argument passing. You could even do this with a separate formula interface, and leave the current more general interface as is.

There may be some issues here that I haven't considered and you already have, making this harder than my gut instinct is leading me to believe. But if not, I think it's worth considering touching up the interface to use formulas.

We're definitely trying to avoid formulas and model frames as it doesn't fit with the style or intent of other tlverse packages