0
我確定我在這裏丟失了一些明顯的東西。我估計使用plm包的幾個模型,然後使用htmlreg和knitr打印它們。在htmlreg中使用字符向量
我用下面的代碼來生成HTML輸出
htmlreg(list(perf1.fe,perf1.re),stars=c(0.001,0.01, 0.05,0.1))
我的問題是,我要打印每13款不同型號的變量。所以我想使下面的代碼工作
felist <- paste0("perf",c(1:13),".fe")
relist <- paste0("perf",c(1:13),".re")
htmlreg(list(union(felist,relist),bold="0.10",stars = c(0.001,0.01, 0.05,0.1))
的一種方式。當我運行上面的代碼中,我得到以下錯誤
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘extract’ for signature ‘"character"’
更新:包括重複的例子,使用LM
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
random_num <- runif(20)
lm.D1 <- lm(weight ~ group)
lm.D2 <- lm(weight ~ group + random_num)
lm.D1_wo_int <- lm(weight ~ group - 1) # omitting intercept
lm.D2_wo_int <- lm(weight ~ group + random_num - 1) # omitting intercept
library(texreg)
htmlreg(list(lm.D1,lm.D2,lm.D1_wo_int,lm.D2_wo_int))
lmlist1 <- paste0("lm.D",c(1,2))
lmlist2 <- paste0("lm.D",c(1,2),"_wo_int")
lmlist <- union(lmlist1,lmlist2)
htmlreg(list(lmlist))
感謝您的幫助
感謝您的輸入,但使用MGET的提供了以下錯誤'錯誤在(函數(類,FDEF,mtable): 無法找到函數「提取」簽字「‘名單’」' – Rfan
@Rfan我不能重現該問題請參閱更新的答案繼承的方法 –
'htmlreg(as.list(mget(lmlist)))'解決了這個問題。感謝您提供'mget' – Rfan