sqldf具有獲取'X'行的限制選項。我們是否也可以使用sqldf做一個'x%'樣本?使用SQLDF的示例行
例如
> sqldf("select * from iris limit 3")
Loading required package: tcltk
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
> sqldf("select * from iris sample 0.01")
Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: near ".1": syntax error
有沒有一些解決方法呢?
Manish
這是一個完全有效的問題,但有您使用的是''R'一個sqldf'原因?爲什麼不是純粹的SQL?或者,如果你喜歡,爲什麼R中的另一個解決方案在這裏不適合? – Hugh
由於問題是一個SQL問題,可能重複[this one](http://stackoverflow.com/questions/5615172/mysql-limit-by-a-percentage-of-the-amount-of-records) – Tensibai
@Hugh - 我來自SQL背景。在sqldf中更方便地更改表/子查詢列和行/組bys/havings等等。因此,希望在SQL中執行所有操作,然後執行Sample行。 – myloginid