vignettes/model_initialisation.Rmd
model_initialisation.Rmd
The t3 process was built under R’s R6 reference classes. R6 is an implementation of encapsulated object-oriented programming for R. This style of programming is also sometimes referred to as classical object-oriented programming. An online documentation was available at https://r6.r-lib.org and you can find a brief introduction and overview in the chapter 14 of the book “Advanced R” written by Hadley Wickham (online view was available here).
Just to sum up, among other things we choose R6 for the t3 process because:
all the methods, or function/process if you want to match with R’s current typology, are encapsulated in a class. You can make anymore mistake when you run a process (for example with functions how doors the same name in two different package).
you can use the process of inheritance from an existing class to another. All your methods work in synergy and transparency.
class are defined with attributes and controls are associated to them to ensure data consistency. When a class was built, you could be sure of what you have inside!
you manipulate class of a data model how represent a vision of reality more understandable. For example, when you manipulate and object of class “trip”, this object contains all attributes necessary to define a trip.
you can optimise and increase the running speed of your process, especially related to the R’s memory usage and the identification of treatments/functions associated.
All documentation regarding class and methods associated are
available thought the navigation bar Reference
in the
section R6 class
. For example, if you search the main t3
process you can find them in the documentation of the class
full_trip
. This documentation, like the other one, is also
available when the call the function help in the R console (for example
above ?full_trip
).
You have three different ways to launch the model creation:
through the function t3::t3_process()
. This function
can run all the t3 process or just a part of it. Use this way if you
planned to run the process at least until the level 1. This function not
allow switching with several data sources and work only with a t3
database as data source. If you want to customise or change this kind of
parameter prefer to use the basic functions (see the third
option).
the second possibility is thought the function
t3::data_model_initialisation()
. Just like the previous
one, you can’t switch with another data sources as t3 database.
Furthermore, this function run all the processes related to the data
model creation and the selection of data associated (in relation to
function parameters provided, see function help for more
details).
the last way is to use all the different sub-functions of the
data model creation process. All the sub-functions, and documentations
associated, were available under methods of the class
?t3::object_model_data()
for the data importation process
and under several methods of the class ?t3::full_trips()
for the model creation and data selection. The table below summarise all
different processes and code/method associated.
Process | Code/method associated | Class(es) associated |
---|---|---|
Initialisation R object for data’s object model | object_model_data$new() |
object_model_data |
Create trips object | trips_object_creation() |
object_model_data, trip, trips |
Create activities object | activities_object_creation() |
object_model_data, activity, activities |
Create elementary catches object | elementarycatches_object_creation() |
object_model_data, elementarycatch, elementarycatches |
Create elementary landings object | elementarylandings_object_creation() |
object_model_data, elementarylanding, elementarylandings |
Create wells object | wells_object_creation() |
object_model_data, wells, well, samples, elementarywellplan |
Create set durations object | setdurationrefs_data() |
object_model_data |
Create length steps object | lengthsteps_data() |
object_model_data |
Create sample sets object | samplesets_data() |
object_model_data |
Create length weight relationships object | lengthweightrelationships_data() |
object_model_data |
Initialisation of R object for full trips class | full_trips$new() |
full_trips |
Create full_trip object | create_full_trips() |
full_trips |
Add activities to trip(s) selected | add_activities() |
full_trips |
Filter on reference year(s) | filter_by_time_period_reference() |
full_trips |
Add elementary catches to trip(s) selected | add_elementarycatches() |
full_trips |
Add elementary landings to trip(s) selected | add_elementarylandings() |
full_trips |
Add well(s) and sample(s) to trip(s) selected | add_wells_samples() |
full_trips |