Use verb in the file name, section name, and function name
8_entry_model to 8_estimate_entry_model# travel frequency to adjecent mesh to # make travel frequency to adjecent meshDo not use . in the file, object, and variable names. Use _ instead.
_ works in C/C++ but . does not. Write robust object names for translation into C/C++.Use Ctrl+Shift+R to make a section in RStudio.
By doing so, the table of contents are automatically generated in RStudio.
When making a subsection, add one # and remove one -.

Don’t use the plural in the file name, section name, or function name
In each file, load relevant data at the beginning, transform data next, analyze the transformed data, and report the results. These steps should be Do not mix up these steps inside a file.
Put a space after ,, ), } and so on. Put spaces before and after =.
Break lines when there are more than one arguments in a function-like:
gpu_output <-
foreach (
i = 1:nrow(gpu),
.combine = "rbind"
) %dopar% {
model_i <-
gpu[i, ] %>%
dplyr::pull(model)
release_i <-
gpu[i, ] %>%
dplyr::pull(release)
time_i <- paste(release_i, current_date)
trend_i <-
gtrendsR::gtrends(
keyword = model_i,
time = time_i
)
trend_i <- trend_i$interest_over_time
return(trend_i)
}
dplyr::mutate format.
magrittr for %>% and foreach for %do% and %dopar%.ggplot2, modelsummary, etc.%>% should be used only for a sequence of operations comprising a single meaningful task.
%>%.dplyr::left_join. Never use other joins such as dplyr::full_join and dplyr::inner_join.
dplyr::left_join followed by dplyr::filter.Ctrl + Shift + R, you can insert a section and generate a table of contents. Use them to structure the code.purrr::map.
purrrr::map to run multiple regressions and obtain the results in another list.figure_long.png and figure_short.png. They should not be like figure.png and figure_short.png. If you added figure_short.png later, make sure to rename figure.png to figure_long.png.output and figuretable, make a subfolder of the code file’s name and save it in the subfolder.
main/estimate_parameters.R, then make a subfolder output/estimate_parameters/ and save files in it.