rbind in for loop not working as expected

24 Views Asked by At

Run as separate statements, this appends dataframes as expected:

queryme<-as.character(sqldf(paste("select SQLStatement from missing_extra_eval_snow where ID = ", 1 )))
output<-dbGetQuery(jdbcConnection, queryme)
snowme<-rbind(snowme,output)

queryme<-as.character(sqldf(paste("select SQLStatement from missing_extra_eval_snow where ID = ", 2 )))
output<-dbGetQuery(jdbcConnection, queryme)
snowme<-rbind(snowme,output)

queryme<-as.character(sqldf(paste("select SQLStatement from missing_extra_eval_snow where ID = ", 3 )))
output<-dbGetQuery(jdbcConnection, queryme)
snowme<-rbind(snowme,output)

But when I put it in a loop it only keeps the values for the last loop, what am I missing?

for(id in idlist)

{

queryme<-as.character(sqldf(paste("select SQLStatement from missing_extra_eval_snow where ID = ", id )))
output<-dbGetQuery(jdbcConnection, queryme)
snowme<-rbind(snowme,output)


}
0

There are 0 best solutions below