Names have been attached to the five elements of a list of dataframes clusts as follows:
names(clusts) = paste("clust",1:length(clusts),sep="")
The names are as desired:
print(names(clusts))
"clust1" "clust2" "clust3" "clust4" "clust5"
However - as one might guess - those names are limited in scope to the list itself - and in particular are not visible in the global scope :
print(ls())
"clusts" (and others..)
This leads to sqldf not being able to "see" those dataframes.. Is there a way to make them visible at the global scope (and thus to sqldf) ?
Update Tried using with per comment of @thelatemail :
with(clusts,
meanDfs2<-lapply(clustxs, function(clustx) {
clust = clustx[[1]]; x = clustx[[2]]
return(ssql(str('select cid, count(1) cnt from clust',x,' group by cid order by 2 desc')))
})
)
But it does not seem to be working:
Error in rsqlite_send_query(conn@ptr, statement) : no such table: clust1
It was a nice idea though!
?withmaybe? Likewith(clusts, <sqldf code here>)fn$sqldfwork for this case?sqldfis not the issue . also: what isfnhere?fn$sqldf(paste0('select cid, count(1) cnt from clusts$clust',x,' group by cid order by 2 desc'))