可以通过sqldf软件包中的read.csv.sql()或read.csv2.sql()直接进入SQLITE。
从在线手册:
链接
Example 13. read.csv.sql and
read.csv2.sql read.csv.sql is an
interface to sqldf that works like
read.csv in R except that it also
provides an sql= argument and not all
of the other arguments of read.csv are
supported. It uses (1) SQLite s import
facility via RSQLite to read the input
file into a temporary disk-based
SQLite database which is created on
the fly. (2) Then it uses the provided
SQL statement to read the table so
created into R. As the first step
imports the data directly into SQLite
without going through R it can handle
larger files than R itself can handle
as long as the SQL statement filters
it to a size that R can handle. Here
is Example 6c redone using this
facility:
# Example 13a.
library(sqldf)
write.table(iris, "iris.csv", sep = ",", quote = FALSE, row.names = FALSE)
iris.csv <- read.csv.sql("iris.csv",
sql = "select * from file where Sepal_Length > 5")
# Example 13b. read.csv2.sql. Commas are decimals and ; is sep.
library(sqldf)
Lines <- "Sepal.Length;Sepal.Width;Petal.Length;Petal.Width;Species
5,1;3,5;1,4;0,2;setosa
4,9;3;1,4;0,2;setosa
4,7;3,2;1,3;0,2;setosa
4,6;3,1;1,5;0,2;setosa
"
cat(Lines, file = "iris2.csv")
iris.csv2 <- read.csv2.sql("iris2.csv", sql = "select * from file where Sepal_Length > 5")