I have an R function programmed to stop when input is not a call from "aov()"
or "lm()"
.
Below, I expect when using fit3
as input for my function to stop
, but I'm wondering why it does not?
P.S. The function correctly stops when fed fit4
but doesn't stop when fed fit3
; WHY?
fit2 <- aov(mpg ~ wt, data = mtcars)
library(rstanarm)
fit3 <- stan_glm(mpg ~ wt, data = mtcars) # This call is from "rstanarm" package !!
fit4 <- glm(vs~mpg, data = mtcars)
bb <- function(fit = NA){
if(!(any(is.na(fit)))){
if(fit$call[1] != "lm()" && fit$call[1] != "aov()") stop("Error")
}
}
# Examples of use:
bb(fit = fit4) # stops as expected ! because call is not from "lm()" or "aov()"
bb(fit = fit3) # I expect the function to stop why it doesn't? !!!!
Aucun commentaire:
Enregistrer un commentaire