Search code examples
rvariable-assignmentsummary

Error when running summary function


I have defined MV1 below with a value, and have used the MV1 in the output name. But when I try to run the summary function on my model output I get the following meesage 'Error: unexpected symbol in: "assign(paste("Model", MV1, sep = '') <- model1 summary" '

MVx is a value that is defined as a numeric in my code already, and MV1 equates to "_3" in my code.

MV = MVx+1
MV1= paste("_", MV, sep="")

assign(paste("Model", MV1, sep = '') = model1 <- 
              glm(tv1~., family=binomial(link='logit'), data=train70)

summary(Model_3) #Error occurs here

Would anyone know how to get around that? I'm not sure my assign(paste("Model", MV1, sep = '') is correct for what i'm trying to do even though I don't get an error messege.

Any help with will be great.

Thanks


Solution

  • I think your assign is wrong. Note the , instead of = and you forgot the last bracket. And as pointed by 42, you get rid of model1 <-

    assign(paste("Model", MV1, sep = '') , glm(tv1~., family=binomial(link='logit'), data=train70))