R- sqldf error raw vs double

心不动则不痛 提交于 2019-12-02 04:53:16

I believe the error lies in your lims object.

lims <- c(0.000000,  7.025894,  9.871630, 12.411131, 
          15.155998, 18.099176, 21.431354, 25.391163, 
          30.616550, 40.356630)

lims[1]<- -0.00001 
a<-data.frame(lims[2:10])
colnames(a)<-'maxSc'
a<-rbind(a, 100) 
lims<-data.frame(lims)
lims$maxSc<-a
colnames(lims)<-c('minSc', 'maxSc')
sapply(lims, class)

#     minSc        maxSc 
# "numeric" "data.frame" 

Notice that lims$maxSc is of type data.frame. Then the following query doesn't work and results in the error you posted.

library(sqldf)
sqldf("select * from lims")

However, if instead lims$maxSc is set to a[,1] then there is no error.

lims$maxSc<-a[,1]
sapply(lims,class)
#     minSc     maxSc 
# "numeric" "numeric" 
sqldf("select * from lims")

The columns of your data.frame cannot be of class data.frame for sqldf to work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!