Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce teal_data class #75

Closed
wants to merge 15 commits into from
Closed

Introduce teal_data class #75

wants to merge 15 commits into from

Conversation

gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Oct 4, 2023

Following introduction of teal_data class

early-dev/app.R Outdated Show resolved Hide resolved
@gogonzo gogonzo changed the title Introduce teal_data Introduce teal_data class Oct 4, 2023
@gogonzo gogonzo linked an issue Oct 5, 2023 that may be closed by this pull request
@gogonzo gogonzo added the core label Oct 5, 2023
@@ -12,6 +12,7 @@ options(shiny.useragg = FALSE)

nest_logo <- "https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/PNG/nest.png"


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually there is only one blank line between nest_logo and everything that comes after

Suggested change

early-dev/app.R Outdated Show resolved Hide resolved
RNA-seq/app.R Outdated Show resolved Hide resolved
efficacy/app.R Outdated Show resolved Hide resolved

# <code
# set join_keys
data@join_keys <- cdisc_join_keys(!!!datanames)
Copy link
Contributor Author

@gogonzo gogonzo Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to fix this:

We need to reconsider following functions to have a robust and easy api.

  • join_keys
  • cdisc_join_keys
  • get_cdisc_keys
  • get_join_keys

First though is:

jk <- join_keys() # constructor
join_keys(jk) <- # setter
join_keys(jk) # getter

Above means that if join_keys could be a getter, then ``get_join_keyscould be removed. Settingjoin_keys` should be possible using:

join_keys(data)["dataset", "dataset"] <- character
join_keys(data) <- join_keys # set or replace whole keys object

cdisc_join_keys is just a wrapper around join_keys constructor - not possible to set nor get keys using this function. Most probably should have the same assertion for ... as join_keys

cdisc_join_keys()

get_cdisc_keys() could change - now it returns a list, but it could return JoinKeys. Unfortunately, get_cdisc_keys() is used widely across all packages. We will need to make a relevant changes there also (teal.transform :()

get_cdisc_keys(c("ADSL", "ADTTE", ...)) # returns JoinKeys

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about getting and setting keys on cdisc data with join_keys methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about getting and setting keys on cdisc data with join_keys methods?

Not sure what you mean.


The way I see setting of the JoinKeys

data <- teal_data()
data <- within(data, {
  ADSL <- synthetic_cdisc_data("latest")$adsl
  ADRS <- synthetic_cdisc_data("latest")$adrs
  ADLB <- synthetic_cdisc_data("latest")$adlb
  ADELO <- ADLB
})
join_keys(data) <- join_keys() # technically it's (and should be) a default in teal_data()

datanames <- c("ADSL", "ADRS", "ADLB", "ADELO")
join_keys(data) <- default_cdisc_keys(datanames) # should warn about missing keys for any of the datasets
join_keys(data)["ADELO"] <- get_cdisc_keys("ADLB")
join_keys(data)["ADELO", "ADSL"] <- c("STUDYID", "USUBJID")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cdisc_data is dropped as a class, this is almost exactly what I meant.
Can we have one function to generate the keys? join_keys(..., cdisc = FALSE) I may be missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I'm thinking there should be cdisc_data package with cdisc_join_keys and cdisc_data function maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHAT IF JoinKeys will be just a list with S3 class??
We could then drop many dependencies in other packages where JoinKeys are needed (teal.transform)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds nice 👍

early-dev/app.R Outdated Show resolved Hide resolved
efficacy/app.R Show resolved Hide resolved
exploratory/app.R Show resolved Hide resolved
@gogonzo
Copy link
Contributor Author

gogonzo commented Nov 8, 2023

Opened a new PR to implement simplified JoinKeys api

#92

@gogonzo gogonzo closed this Nov 8, 2023
@gogonzo gogonzo deleted the teal_data@main branch November 8, 2023 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[summary] data refactor
4 participants