Inline comments ideally want to convey what the line(s) below is doing. For example, the following comment is not quit informative, and can be deleted if the operation is obvious.
# Store all variable names in 'varnames'
varnames <- list(y, x, c)
You can use underscore _ to separete words in a variable, for example, var_names instead of varnames (or group_names instead of groupname).
The logic in this file looks great overall! I applied only stylistic edits, no logic has been changed.
In general, I recommend following a style guide such as https://style.tidyverse.org/; you can apply the styler to the existing files by calling
styler:: style_file("path_to_file.R")
(see https://www.tidyverse.org/blog/2017/12/styler-1.0.0 for more details).Inline comments ideally want to convey what the line(s) below is doing. For example, the following comment is not quit informative, and can be deleted if the operation is obvious.
You can use underscore
_
to separete words in a variable, for example,var_names
instead ofvarnames
(orgroup_names
instead ofgroupname
).