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

The [mmrm] package is missing in the repo (it was there previously) #391

Closed
adrianolszewski opened this issue Mar 26, 2024 · 5 comments
Closed
Labels
package request This is a request for a Wasm package

Comments

@adrianolszewski
Copy link

adrianolszewski commented Mar 26, 2024

Recently I reported an issue regarding the mmrm package when running the code in https://webr.r-wasm.org/latest/ (actually caused by one of the dependencies, TMB; #386).

Today I wanted to play in the webr editor and also in the livecode one - where mmrm loaded and worked properly.

While in the livecode.io it is loaded normally:

Loading WebR...

WebR is using `PostMessage` communication channel, nested R REPLs are not available.

WebR loaded.

Installing packages: mmrm

Downloading webR package: backports
Downloading webR package: checkmate
Downloading webR package: cli
Downloading webR package: glue
Downloading webR package: rlang
Downloading webR package: lifecycle
Downloading webR package: lattice
Downloading webR package: nlme
Downloading webR package: numDeriv
Downloading webR package: Rcpp
Downloading webR package: rbibutils
Downloading webR package: Rdpack
Downloading webR package: magrittr
Downloading webR package: stringi
Downloading webR package: vctrs
Downloading webR package: stringr
Downloading webR package: Matrix
Downloading webR package: RcppEigen
Downloading webR package: TMB
Downloading webR package: brio
Downloading webR package: ps
Downloading webR package: R6
Downloading webR package: processx
Downloading webR package: callr
Downloading webR package: desc
Downloading webR package: digest
Downloading webR package: evaluate
Downloading webR package: jsonlite
Downloading webR package: crayon
Downloading webR package: fs
Downloading webR package: pkgbuild
Downloading webR package: rprojroot
Downloading webR package: withr
Downloading webR package: pkgload
Downloading webR package: praise
Downloading webR package: diffobj
Downloading webR package: fansi
Downloading webR package: utf8
Downloading webR package: pillar
Downloading webR package: pkgconfig
Downloading webR package: tibble
Downloading webR package: rematch2
Downloading webR package: waldo
Downloading webR package: testthat
Downloading webR package: mmrm

...the web-r editor fails to load it:

> library(mmrm)
Failed to load package "mmrm". Do you want to try downloading it from the webR binary repo? 

1: Yes
2: No

Selection: Yes
Warning message:
In webr::install(package) :
  Requested package mmrm not found in webR binary repo.

I don't know if livecode.io uses own, separate version of the packages library, but if not, then something strange is happening...

Is there any chance to restore this package in future to the repository? It's one of the core packages for analysing longitudinal data in clinical trials.

PS: just thought that maybe it's related to the recent web R upgrade and needs recompiling the packages, which takes time?

@georgestagg
Copy link
Member

georgestagg commented Mar 26, 2024

I'll investigate to see why the app is no longer building.

In the meantime, you should still be able to load the package in the older fixed version of the app at https://webr.r-wasm.org/v0.2.2/, rather than at /latest/.

@georgestagg georgestagg added the package request This is a request for a Wasm package label Mar 26, 2024
@georgestagg
Copy link
Member

Due to restrictions in the WebAssembly environment, not all R packages work with webR. It looks like the last version of the mmrm package that worked with webR was version 0.2.2.

I can re-upload version 0.2.2 to the webR repository for /latest, but the package will not receive further updates for the time being.

@georgestagg
Copy link
Member

I've pushed the older mmrm v0.2.2 to the webR repo for /latest, you should be able to load it there now.

Although the TMB package seems to require a compiler for full functionality, and library(TMB) does still fail, it looks like it can still be used in a limited fashion under webR. However, due to an assumption that the package makes about where it can write files it needs to be loaded in a slightly different way with an extra argument mount = FALSE.

So, please try installing and using TMB and mmrm in the following way when running in like this in https://webr.r-wasm.org/latest/ :

webr::install("TMB", mount = FALSE)
webr::install("mmrm")
webr::install("dplyr")

library(dplyr)
library(mmrm)
set.seed(0228)

d <- bind_rows(expand.grid(visit = 1:20, subject = 1:200, trt = "a") %>%
                   mutate(aval = rbeta(nrow(.), 7, 1)),
               expand.grid(visit = 1:20, subject = 201:400, trt = "b") %>%
                   mutate(aval = rbeta(nrow(.), 4, 1))) %>%
    mutate(visit = factor(visit),
           subject = factor(subject))

unique_visits <- unique(d$visit)

for (i in seq_along(unique_visits)) {
    these_rows <- which(d$visit == unique_visits[i])
    d$aval[these_rows] <- d$aval[these_rows] *
        rbinom(n = length(these_rows), size = 1, prob = 1 / as.numeric(unique_visits[i]))
}

d <- d[d$aval != 0, ]

fit1 <- mmrm(aval ~ trt + ar1(visit | subject), data = d)
summary(fit1)$coefficients

@adrianolszewski
Copy link
Author

@georgestagg Thank you wholeheartedly!
In the meantime, maintainers of the TMB also pushed things forward.
Please check: #386 (comment)

@georgestagg
Copy link
Member

With the changes in #386, mmrm now seems to work. I'll close this thread as complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package request This is a request for a Wasm package
Projects
None yet
Development

No branches or pull requests

2 participants