*kohei-kawaguchi-sunada*August 30, 2022 1:54 PM (GMT+8)August 30, 2022 1:54 PM (GMT+8)
You don't have to call a package in this way if you call each function as dplyr::mutate.
**August 30, 2022 1:54 PM (GMT+8)August 30, 2022 1:54 PM (GMT+8)August 30, 2022 1:54 PM (GMT+8)

**August 30, 2022 1:55 PM (GMT+8)August 30, 2022 1:55 PM (GMT+8)August 30, 2022 1:55 PM (GMT+8)
I make foreach, magrittr, and some other packages like ggplot2 and modelsummary exceptions and call them by library. August 30, 2022 1:55 PM (GMT+8)
**August 30, 2022 1:56 PM (GMT+8)August 30, 2022 1:56 PM (GMT+8)August 30, 2022 1:56 PM (GMT+8)
This one should be like the next

**August 30, 2022 1:56 PM (GMT+8)August 30, 2022 1:56 PM (GMT+8)August 30, 2022 1:56 PM (GMT+8)

**August 30, 2022 1:57 PM (GMT+8)August 30, 2022 1:57 PM (GMT+8)August 30, 2022 1:57 PM (GMT+8)
The reason is otherwise the position of the indent can be different depending on the length of words. For example, if it is not data.frame but tibble::tibble, the location of the indent can be different. By breaking the lines as above, you can keep the location of the indent.
**August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)
For the same reason, I make
**August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)

**August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)
into this
**August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)August 30, 2022 1:58 PM (GMT+8)

**August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)
You can use as many lines as you want.
**August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)
It is always better to make arguments explicit. This is especially true for user-written functions.
**August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)August 30, 2022 1:59 PM (GMT+8)

**August 30, 2022 2:00 PM (GMT+8)August 30, 2022 2:00 PM (GMT+8)August 30, 2022 2:00 PM (GMT+8)

**August 30, 2022 2:01 PM (GMT+8)August 30, 2022 2:01 PM (GMT+8)August 30, 2022 2:01 PM (GMT+8)
You can pass additional arguments to optim as follows
**August 30, 2022 2:01 PM (GMT+8)August 30, 2022 2:01 PM (GMT+8)August 30, 2022 2:01 PM (GMT+8)

**August 30, 2022 2:02 PM (GMT+8)August 30, 2022 2:02 PM (GMT+8)August 30, 2022 2:02 PM (GMT+8)

**August 30, 2022 2:03 PM (GMT+8)August 30, 2022 2:03 PM (GMT+8)August 30, 2022 2:03 PM (GMT+8)
This is the same for other functions that have ... in the arguments. You can see this in the help page
**August 30, 2022 2:03 PM (GMT+8)August 30, 2022 2:03 PM (GMT+8)August 30, 2022 2:03 PM (GMT+8)

**August 30, 2022 2:04 PM (GMT+8)August 30, 2022 2:04 PM (GMT+8)August 30, 2022 2:04 PM (GMT+8)
R function definitions can be written in a single function like R/functions.R. In Matlab, we had to make a file for each function.