Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 236
Tidy Conventions
ОглавлениеThe tidyverse also enforces some rules to keep code tidy. The aims are to make code easier to read, reduce the potential misunderstandings, etc.
For example, we remember the convention that R uses to implement it is S3 object oriented programming framework from Chapter 6.2 “S3 Objects” on page 91. In that section we have explained how R finds for example the right method (function) to use when printing an object via the generic dispatcher function print()
. When an object of class “glm” is passed to print()
, then the function will dispatch the handling to the function print.glm()
.
However, this is also true for data-frames: the handling is dispatched to print.data.frame()
. This example illustrate how at this point it becomes unclear if the function print.data.frame()
is the specific case for a data.frame for the print()
function or if it is the special case to print a “frame” in the framework of a call to “print.data().” Therefore, the tidyverse recommends naming conventions to avoid the dot ( .
). And use the snake_style
or UpperCase
style instead.