Hi, so I'm pretty new to R in general. This is the data I'm using-

'data.frame': 40 obs. of 4 variables:

grp: Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
befored:

afterd :
surviv : num 13 69.8 87.5 19.5 18.4 ...

What I want to do is to test if there are significant differences between group survival (surviv) using binomial glm

myfm <- glm(grp~surviva,family=binomial,data=d) = like this

but I want to see which groups specifically are different to each other, and create subsets using a glm to do pairwise testing between groups.

g1 <- subset(d, grp== "1" )

g2 <- subset(d, grp== "2" )

g12 <- subset(d, grp%in% c("1", "2") ) =this is what I did

However, when I try to put it in a glm I get this message which tells me I can't use the subset since it's a list?

fm <- glm(g12~surviva,family=binomial,data=d)

Error in model.frame.default(formula = g12 ~ surviva, data = d, drop.unused.levels = TRUE) :

invalid type (list) for variable 'g12'

I just don't really understand what to do to make it work.