sqldf不为null返回所有行

时间:2018-01-26 14:03:37

标签: r sqldf

我有一个csv文件,其中包含一个帐户处于活动状态和非活动状态的表,我在状态码上过滤帐户,因为我只希望在新的df中拥有状态有效的帐户。这部分有效。接下来我要做的是创建一个新的df,其中包含列telephone1包含数据的所有帐户。我试过的是:

>df <- read.csv2("df.csv")
> df_active_accounts <- sqldf('Select * from df where statecode = 0')
> telephone1 <- sqldf('Select telephone1 from df_active_accounts where telephone1 is not null')

这段代码在df_active_accounts上返回与在telephone1上相同的行数。这导致相信没有不包含数据的行。但是,我确实看到列中不包含数据的行。 我在这里做错了什么?

Column telephone1 has rows which do not contain data

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并以此方式解决了该问题:

telephone1 <- sqldf("Select telephone1 from df_active_accounts where telephone1 <> 'null' ")