I need to check if the formula is one-way (e.g. ~ a , not a~b ).
Now I am doing something like this:
test <- list( ~ a + b, a ~ b + c, b + c ~ a ) isOneSided <- function(form) length(form)==2 && sum(grepl("~",form))==1 > sapply(test,isOneSided) [1] TRUE FALSE FALSE
Is there a better way? I worry, there are types of formulas that I donβt know about that can elude this test.
source share