You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work with version 1.2.0 of the package, downloaded on github, and I have issue to use ZIPLN within (mc)lapply framework to parallelize treatment over different model formulas.
Basically, what I would like to do with ZIPLN is this, which works with the classical PLN function:
library(PLNmodels) # Version 1.2.0
data("barents")
# With PLN ----------------------------------------------------------------
pln_formulas <- c("Abundance ~ 1")
lapply(pln_formulas, function(form_){
PLN(pln_formulas, data = barents)
}) # Works fine
I then define a new formula and I want to use ZIPLN, but this won't work within lapply.
It works if I do it within a loop:
# With ZIPLN --------------------------------------------------------------
ZIPLN("Abundance ~ 1 | 1", data = barents) # Works fine, just to check
# Creating vector of formulas
zi_pln_formulas <- c("Abundance ~ 1 | 1")
# Works fine within a loop using as.formula
for(x in zi_pln_formulas){
ZIPLN(as.formula(x), data = barents)
} # Works fine
However, the following codes won't work (the error is shown in comment each time)
# Using the raw object
ZIPLN(zi_pln_formulas, data = barents)
# Error in x$formula : object of type 'symbol' is not subsettable
# Within a lapply, first as a string
lapply(zi_pln_formulas, function(form_){
ZIPLN(form_, data = barents)
})
# Error in x$formula : object of type 'symbol' is not subsettable
# Within a lapply, with as.formula
lapply(zi_pln_formulas, function(form_){
ZIPLN(as.formula(form_), data = barents)
})
# Error in as.formula(form_) : object 'form_' not found
My R session info is the following
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status Patched
major 4
minor 2.2
year 2022
month 11
day 10
svn rev 83330
language R
version.string R version 4.2.2 Patched (2022-11-10 r83330)
The text was updated successfully, but these errors were encountered:
Hi @papayoun, thanks for finding the bug. I'll have a look into it (it's probably due to the "non standard" formulas used in ZIPLN).
Can you just check something for me: I get an error when I try to use as.formula() within ZIPLN within a loop but your reprex suggests it works for you (I have the same error as the one you get with lapply() or the raw object). Can you confirm this ?
library(PLNmodels)
#> This is package 'PLNmodels' version 1.2.0#> Use future::plan(multicore/multisession) to speed up PLNPCA/PLNmixture/stability_selection.# Creating vector of formulaszi_pln_formulas<- c("Abundance ~ 1 | 1")
# Works fine within a loop using as.formulafor(xinzi_pln_formulas){
ZIPLN(x, data=barents)
} # Works fine for @papayoun # but not for me#> Error in x$formula: objet de type 'symbol' non indiçable
I work with version 1.2.0 of the package, downloaded on github, and I have issue to use
ZIPLN
within (mc)lapply framework to parallelize treatment over different model formulas.Basically, what I would like to do with
ZIPLN
is this, which works with the classicalPLN
function:I then define a new formula and I want to use
ZIPLN
, but this won't work within lapply.It works if I do it within a loop:
However, the following codes won't work (the error is shown in comment each time)
My
R
session info is the followingThe text was updated successfully, but these errors were encountered: