"Error: near ".": syntax error" with sqldf in R
"Error: near ".": syntax error" with sqldf in R
出于某种原因,我以前可以工作的代码不再工作了,我收到以下错误消息 "Error: near "。“:语法错误”。代码如下。我应该如何修改它以使其再次工作?
非常感谢!
uhc_phys <- sqldf("select
a.iso3,a.year,a.whoname,a.Phys
b.iso3,b.year,b.whoname,b.Phys
min(abs(a.year - b.year)) min_value
from uhc_hwf a
left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
a.iso3 = b.iso3 and
b.Phys is not null
group by a.iso3, a.year
having a.year in ('2012','2017')")[1:8]
您在某些所选字段之间缺少逗号。试试这个:
uhc_phys <- sqldf("select
a.iso3,a.year,a.whoname,a.Phys ,
b.iso3,b.year,b.whoname,b.Phys ,
min(abs(a.year - b.year)) min_value
from uhc_hwf a
left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
a.iso3 = b.iso3 and
b.Phys is not null
group by a.iso3, a.year
having a.year in ('2012','2017')")[1:8]
(逗号隔开一点以突出显示缺少的内容。)
出于某种原因,我以前可以工作的代码不再工作了,我收到以下错误消息 "Error: near "。“:语法错误”。代码如下。我应该如何修改它以使其再次工作? 非常感谢!
uhc_phys <- sqldf("select
a.iso3,a.year,a.whoname,a.Phys
b.iso3,b.year,b.whoname,b.Phys
min(abs(a.year - b.year)) min_value
from uhc_hwf a
left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
a.iso3 = b.iso3 and
b.Phys is not null
group by a.iso3, a.year
having a.year in ('2012','2017')")[1:8]
您在某些所选字段之间缺少逗号。试试这个:
uhc_phys <- sqldf("select
a.iso3,a.year,a.whoname,a.Phys ,
b.iso3,b.year,b.whoname,b.Phys ,
min(abs(a.year - b.year)) min_value
from uhc_hwf a
left join uhc_hwf b on a.year - b.year in (0,1,2,3,4,5) and
a.iso3 = b.iso3 and
b.Phys is not null
group by a.iso3, a.year
having a.year in ('2012','2017')")[1:8]
(逗号隔开一点以突出显示缺少的内容。)