Error in terms.formula(formula, data = data) : '.' in formula and no 'data' argument

5.3k Views Asked by At

i created a GUI for regression analysis.

svalue(tbl[2,1]) : accept a .csv input file

svalue(tbl[4,1]) : provide a dependent variable

enter code here


selected_var=read.csv(svalue(svalue(tbl[2,1]))
sv=selected_var

sv_regression=data.frame(sv)
glm1<<-glm(svalue(tbl[4,1]) ~ . ,data = sv_regression,family = poisson)
reg<<-summary.glm(glm1)$coefficients

reg_result <<-gtable(reg)
add(frame1,reg_result,expand=TRUE)

now run this code, i got an error

Error in terms.formula(formula, data = data) : '.' in formula and no 'data' argument

1

There are 1 best solutions below

0
On

glm() and other modelling functions need a formula in this structure:

`glm(var1 ~ ., data = sv_regression, family = poisson)

Where var1 should be the name of the response variable you are trying to predict. Without knowing what tbl and svalue are I can't see exactly what's going wrong (I suspect at least three things), but you need to structure your data in a way that you know in advance the name of the variable to be on the left side of the formula in your statistical model.

For example, given you are dependent on the user choosing things in the GUI, you could rename the column in sv_regression that is to be the response variable as y (or something more distinctive that has less chance of causing a conflict with an existing name), before you call glm. Then when you call glm you know that it will by glm(y ~ ., ...)