2011-09-14 19 views
2

私は、次のコマンドを実行している:SQLDFエラー - 構文エラー

sqldf("SELECT * FROM dat WHERE Form LIKE '%compare%' AND Create.Date LIKE '%7/01/11%' AND Post.Status = 'Success'") 

が、次のエラーを取得してしまいます。

Error in sqliteExecStatement(con, statement, bind.data) : 
    RS-DBI driver: (error in statement: near "Create": syntax error) 

誰でも教えてください。

> str(dat) 
'data.frame': 23 obs. of 12 variables: 
$ ID   : int 4873 4874 4890 4893 4895 4902 4904 4905 4906 4921 ... 
$ Name   : Factor w/ 18 levels "Casey Ryan","Elizabeth Cullen",..: 13 9 15 15 16 15 15 15 16 12 ... 
$ Create.Date : Factor w/ 23 levels "03:23.0","14:43.0",..: 3 15 20 13 23 6 12 14 21 4 ... 
$ In.Click.ID : int 32787 32788 13480 21050 21041 32824 27807 27806 15350 32911 ... 
$ Traffic.Source: Factor w/ 3 levels "FACEBOOK","GOOGLE",..: 3 3 1 3 2 3 3 3 2 3 ... 
$ Refer.Domain : Factor w/ 7 levels "","autoinsurancestep",..: 3 2 7 1 2 4 4 2 5 4 ... 
$ Form   : Factor w/ 3 levels "","autoinsurancestep",..: 2 1 1 1 3 3 3 3 1 3 ... 
$ Keyword  : Factor w/ 3 levels "","{keyword}",..: 1 1 2 1 3 1 1 1 2 1 ... 
$ Ping.Status : Factor w/ 2 levels "","Success": 1 2 1 1 1 2 1 1 1 2 ... 
$ Post.Status : Factor w/ 2 levels "","Success": 1 2 1 1 1 2 1 1 1 2 ... 
$ Buyer   : Factor w/ 8 levels "","ALL_WEB_LEADS",..: 1 6 1 1 1 7 1 1 1 8 ... 
$ Amount  : int 0 217 0 0 0 3000 0 0 0 1200 ... 
+2

おそらく 'dput(head(dat)) 'を使って、' dat'の構造に関する情報を提供したら助けになります。 – joran

+0

'?sqldf'の例をスキャンするだけで、変数名のピリオドが問題になるようです。虹彩データセットを使用する例に注意してください。代わりにアンダースコアを使用するか、列全体の名前を変更してみてください。 – joran

+0

これとは別に、私はあなたの 'dat'変数が" 03:23.0 "で、あなたがしようとしているので、あなたがCreate.Dateとマッチするつもりはないと思います。 %7/01/11%でマッチする(私は間違っているかもしれませんが、他の21レベルのうちの1つがそれにマッチするかもしれませんが)。 –

答えて

1

SQLでは、ドットはデータベース名とテーブル名を区切ります。したがって、名前にドットを使用しないでください。