error r: invalid subscript type “closure” in a simple regression

unfortunately i am a beginner in r. I d like to run a simple linear regression model in r with the comand lm, but every time i try the following error occurs:

Error in xj[i] : invalid subscript type ‘closure’

The regression model ist just as follows:

REG1 <- lm(flowpercent~ret+tna+fundage+number_shr_cl,data = reg, na.omit)
 #-flowpercent is a calculated variable:

reg$flowpercent <- reg$flow_dollar/lag(reg$tna, n=1)

 #-fundage is also calculated:

reg$fundage <- as.numeric(difftime(ref_date,reg$InceptionDate, units = "days")/365.25)

ret, tna, number_shr_cl are variables from a database

hopefully some can help me to solve my problem.

Many thanks in advance.

Leave a Comment