Replies: 3 comments
-
|
Hi, I'm trying to translate my teal app based on teal version < v.0.14 to the latest release v.0.15. The problem is with setting primary and foreign keys. I've read the materials + join key vignitte https://insightsengineering.github.io/teal.data/latest-tag/articles/join-keys.html#anatomy-of-join_keys but still I cannot figure out the issue of the app - it still throws an error that "extracted data has not correctly set joining keys" #I need to simply translate old code to teal migration:
app <- init(
data = teal_data(
dataset("x", x, keys=c("id"))
),
modules=modules(
tm_g_response("Response",
response = response2,
x = response1,
row_facet = NULL,
col_facet = data_extract_spec(
dataname = "x",
filter = filter_spec(
vars = vars,
choices = value_choices(x, vars$selected),
selected = value_choices(x, vars$selected),
multiple = T
)
),
coord_flip = FALSE
)
))
)
#I tried this but it didn't worked in v0.15.0:
data<- within(teal_data(), {
x=x
response1=response1
response2=response2
})
datanames <- c("x", "response1", "resposne2")
datanames(data) <- datanames
join_keys(data) <- join_keys(
join_key("x", keys = c("id")),
join_key("response1", keys = c("id")),
join_key("response2", keys = c("id")),
join_key("response1", "response2" keys = c("id"="id"))
)
app <- init(data=data,
modules=modules(
tm_g_response("Response",
response = response2,
x = response1,
row_facet = NULL,
col_facet = data_extract_spec(
dataname = "x",
filter = filter_spec(
vars = vars,
choices = value_choices(x, vars$selected),
selected = value_choices(x, vars$selected),
multiple = T
)
),
coord_flip = FALSE
)
)
)
I would appreciate your help |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Mia-data
Would be easiest if you just send us the code of the former (working) application so we can help you directly - if it contains sensitive data please just replace sensitive information with some more implicit names/paths/symbols. It is hard to deduce from the code you've provided |
Beta Was this translation helpful? Give feedback.
-
|
Hi @gogonzo, I have opened also the issue here #1164 (comment) so I will continue provide more info there to avoid duplication of the topic. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Migrate from
TealDatatoteal_dataThe CRAN release of
teal(v0.15.0) brings major changes the way data is created and processed byteal, streamlining data flow acrosstealmodules and makingtealpackages much easier to maintain.The
dataargument inteal::initno longer accepts theTealDataclass, the basic data container is now theteal_dataclass.We introduce a method for the base function
withinas a convenient way to run code within the data container.We also introduce the
teal_data_moduleconcept for cases when theteal_datacontainer must be built during the application run time.The table below shows how to adjust your existing apps to the new class and the following text that explains the changes in more detail.
Changes summary
Execute this code to obtain old `teal` (<=0.14.0) datasets `rADSL` and `rADTTE`. (click)
It is no longer necessary to specify code for individual datasets. 'teal.data::get_code()' can extract the code necessary to reproduce a specific dataset, using the `datanames` argument.
Create simple data
Until now, supply data to a
tealapplication was a multi-step process, where one would pass data objects to thedataset()function to create "datasets" and then include the datasets toteal_data()to create the final data container.Now data objects are passed directly to
teal_data().Note that this way of specifying data is recommended only in case where no reproducible code is necessary.
Including data in
tealapplications is detailed in this vignette.Create reproducible data
Tracking code for reproducibility requires that the data creation code be included in the
teal_dataobject.In old
tealthis was done by creating data objects by running code in the global environment and then passing both the objects and the code toteal_data().While this is still possible, we recommend the superior approach of initializing
teal_dataas an empty container and creating data objects by running code within the container.Keeping the data in an isolated environment from the moment of creation throughout the whole analysis is the best way ensure that the code represenst the data exactly.
A detailed explanation of reproducibility can be found in this vignette.
Access data
The new
teal_dataclass stores data objects much like a list.Objects can be accessed using public functions exported from hte underlying
teal.codepackage.Modify data
The functions
mutate_dataandmutate_datasetare superseeded bywithin.The usage of the functions is similar but
withinaccepts inline R expressions rather thancharacter.(If there is a valid reason to pass code as character, use the
eval_codefunction instead ofwithin.)Note that it is no longer necessary to which data object the code refers to.
The expression is evaluated and changes are directly applied to the contents of the container.
withinalso works withteal_data_module(more on that later).Please visit the "Introduction to teal.data" vignette for more details.
Data validation
The old
TealDataclass had adata$check()method which was used to validate that the code corresponds to the data.The check was done by evaluating the code and comparing the results to the data stored in the object.
This action is now performed by the
verifyfunction, defined in theteal.datapackage.The verification process is described in detail in the
teal_datareproducibility vignette.Join keys
Join keys are now accessed and set with the
join_keysfunction.Running
join_keyson ateal_dataobject returns a list of joining keys.Modifying part of a joining key set is done with the
[operator.A detailed explanation of joining keys can be found in the "Join Keys" vignette.
Connectors
All hitherto existing connector classes and their related functions are now deprecated and we do not offer 1:1 replacements.
The old
Teal*classes containeddata,ui,serverand various other attributes and methods.That solution was not flexible enough to fullfil incoming user requests and also hampered maintenance.
Intead we introduce the
teal_data_moduleconcept.A special
shinymodule is created with theteal_data_modulefunction.The module is passed to a
tealapplication in place of ateal_dataobject and creates data once the application starts.The server function runs all code necessary to connect to an external data source and obtain the desired data objects and returns a
teal_dataobject.teal_data_moduleis thoroughly explained in the "Data as shiny module" vignette.Beta Was this translation helpful? Give feedback.
All reactions