Skip to content
Prev 388431 / 398502 Next

R Function question, (repost to fix the messy work format)

Hard for me to tell without more details but it looks like the following
has several bugs

for (i in dbtable$Tot_table)
{
  Tabname <- as.character(sqldf(sprintf("SELECT Tot_table FROM dbtable",
i)))
  summ(Tabname)
}

Your sprintf() statement seems to use 'i' but actually does not.
You probably want to rewrite/rearrange this code. More like

x <- sqldf("SELECT Tot_table FROM dbtable")
for ( Tabname in x )
summ(Tabname)

no doubt this is wrong but put a browser() call after the x <- sqldf(...)
line and inspect x and go from there
On Fri, Jul 2, 2021 at 10:20 PM Kai Yang <yangkai9999 at yahoo.com> wrote: