sfcheung/semptools

Write a function to convert a named list to the required list of arguments

sfcheung opened this issue · 1 comments

Some functions require users to specify the changes as a list of lists. E.g.,

list(list(node = "x3", rotate =  45),
      list(node = "x4", rotate = -45),
      list(node = "x2", rotate = -90))

This can be difficult to read and write. We can write a function to convert a named list, or even a named vector, to this kind of list. E.g.,

# Option A:
fct(c(x3 = 45, x4 = -45, x2 = -90)) # Return the list in the block above.
# Option B:
fct(list(x3 = 45, x4 = -45, x3 = -90)) # Return the list in the block above.

It is better to write a separate function to do this, for two reasons.

  1. This function can be be used for all other semptools functions.

  2. We do not need to modify the existing functions.

DONE

  • Drafted, to_list_of_lists. Preliminary tests passed.

  • Functions revised (preliminary tests passed).

    • rotate_resid, for the argument rotate_resid_list.

    • set_curve, for the argument curve_list.

    • set_edge_label_position, for the argument position_list.

    • set_sem_layout, for the argument indicator_push, indicator_spread, and loading_position

Done. Functions added, revised, and tested.