Question

I am sure I am missing something obvious here. I am estimating few models using plm package and then printing them using htmlreg and knitr.

I use the following code to generate html output

htmlreg(list(perf1.fe,perf1.re),stars=c(0.001,0.01, 0.05,0.1))

My problem is that I have to print 13 models each with different model variables. So I want a way of making the following code work

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))

When I run the above code I get the following error

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘extract’ for signature ‘"character"’

UPDATE: INCLUDING A REPRODUCIBLE EXAMPLE USING 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))

thanks for your help

Was it helpful?

Solution

You have to create a list of models, not a list of characters strings corresponding to the object names.

This list can be created with mget in the following way:

mylist <- mget(c(lmlist1, lmlist2))

Then you can use htmlreg:

htmlreg(mylist)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top