[R] Function with large nested list

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Dec 18 11:17:39 CET 2023

В Mon, 18 Dec 2023 09:56:16 +0000
Emily Bakker <emilybakker using outlook.com> пишет:

> When i try to run the function definiton, the command never
> "completes" in de console.

How do you run the function definition? I copied and pasted your
example into a character variable and gave it to parse(text = ...). It
parsed successfully.

Splitting the function into multiple smaller functions is the usual
advice. It should help here too. When you decompose a large function
into a set of smaller functions, it becomes easier to reason about them
and test them individually. (It is also possible to have too many small
functions; it is important to find a balanced solution.)

If you find yourself making a decision based on a fixed set of strings,
consider switch() and match.arg(). If a set of possible values for a
factor is limited to true / false / don't know, it may help to switch
to R's native TRUE / FALSE / NA_logical_ values instead of strings
(which may contain typos).

Best regards,

More information about the R-help mailing list