R-sqldf错误原始与双精度

R-sqldf错误原始与双精度,r,sqldatatypes,sqldf,R,Sqldatatypes,Sqldf,我有一个向量lims,有分数的限制: [1] 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<

我有一个向量lims,有分数的限制:

 [1]  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')


> class(lims)
[1] "data.frame"
我想根据这些限制和字段sc对另一个表(列)进行分类:

>class(train$sc)
[1] "numeric"
> class(train$target)
[1] "integer"
但是,当我运行以下命令时,我得到一个错误:

library(sqldf)
sqldf("Select b.minSc, b.maxSc, count(*) as total, sum(target) as compra
     from  train a left join lims b 
    on a.sc<=b.maxSc and a.sc>b.minSc
    group by b.minSc, b.maxSc")
库(sqldf)
sqldf(“选择b.minSc,b.maxSc,count(*)作为总计,sum(target)作为压缩
从a列左转入b列
关于a.scb.minSc
b.minSc、b.maxSc分组)
sqliteSendQuery(conn,statement,bind.data)中出错:RAW()可以 仅适用于“原始”,而不是“双精度”


我不明白我做错了什么。

我相信错误在于您的
lims
对象

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" 
但是,如果将
lims$maxSc
设置为
a[,1]
,则没有错误

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

lims$maxSc我相信错误在于您的
lims
对象

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" 
但是,如果将
lims$maxSc
设置为
a[,1]
,则没有错误

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