Consider the following:
set.seed(1) y <- rbinom(10, 1, prob=.5) x <- runif(10) m <- glm(y~x, family=binomial) s <- summary(m)
I am looking for some function foo(s)that I can use to return "y".
foo(s)
"y"
May be the best answer, but
as.character(attributes(s$terms)$variables[[2]])
work
Another option is
R> strsplit(as.character(s$call)[2],"\\s~\\s")[[1]][1] [1] "y"
If you use the function terms(), you can do
terms()
with(attributes(terms(m)), as.character(variables[response+1])) # [1] "y"
This should be reliable for many different formulas. This is a similar method used by the function delete.response().
delete.response()
Source: https://habr.com/ru/post/1570901/More articles:Run the OpenGL shader to modify the existing texture / frame buffer - cview-based nstableview resizing - objective-cПетля до тех пор, пока файл не будет создан с помощью команды windows batch - fileImplicit conversions causing infinite recursion, but it should not be typecheck - scalaDebug Viewer - UITransitionViews - Xcode - debuggingWhat to replace MethodInvokingTimerTaskFactoryBean with Spring 4? - javaThe for-loop variable violates the loop limit - for-loopLet, eval, and quote behavior - lispAndroid Storage Access Framework - launch selection for custom file type - androidEval and lexical variables - evalAll Articles