emitanaka / edibble

An R-package that encapsulate elements of experimental design for better planning, management, and workflow
https://edibble.emitanaka.org
Other
215 stars 14 forks source link

record_vars #26

Closed emitanaka closed 2 years ago

emitanaka commented 3 years ago

Current API:

des %>%
  record_vars(student = c(quiz1, quiz2),
              class = c(teacher, location))

Which reads as "record variables quiz1, quiz2 for each student and teacher, location for class". But this is contrary with other functions where variables that are created are on LHS, e.g. set_units(plot = 3). So if we follow this principle that newly created variables are on LHS then it should be something like

des %>%
  record_vars(quiz1 = of(student, unit = "%"),
              quiz2 = of(student, unit = "%"),
              teacher = of(class),
              location = of(class))

with also giving an option to specify unit or other information. But this is quite tedious if there are so many record variables! So maybe the solution is to use the original with another verb

des %>%
  record_vars_of(student = c("quiz1", "quiz2"),
                 class = c("teacher", "location"))

so the sentence is more like "record variables of student: quiz1, quiz2; record variables of class: teacher, location". The record variables are quoted as per thinking in #24 . Additionally, an option to record units for this can be something like

des %>%
  record_vars_of(student = c(trait("quiz1", unit = "%"), trait("quiz2", unit = "%")),
                 class = c("teacher", "location"))

This is more acceptable to break-away from LHS=new variable since the function deviates away from <verb>_<noun> set up and this serves as a signal to the user that maybe this has a different setup.

Another option is to substitute vars with traits. The word traits though can have different associations in different fields. Also another part to watch out is that there is a function igraph::traits so potential namespace clash needs to be considered. (Noting though this function in igraph looks like for a particular use case that is unlikely to be needed).