r functions calling lm with subsets
问题 I was working on some code and I noticed something peculiar. When I run LM on a subset of some panel data I have it works fine, something like this: library('plm') data(Cigar) lm(log(price) ~ log(pop) + log(ndi), data=Cigar, subset=Cigar$state==1) Call: lm(formula = log(price) ~ log(pop) + log(ndi), data = Cigar, subset = Cigar$state == 1) Coefficients: (Intercept) log(pop) log(ndi) -26.4919 3.2749 0.4265 but when I try to wrap this in a function I get: myfunction <- function(formula, data,