[R] sqldf syntax, selecting rows, and skipping

Juliet Hannah juliet.hannah at gmail.com
Thu Sep 29 16:06:55 CEST 2011


I am using the example in this post:

https://stat.ethz.ch/pipermail/r-help/2010-October/257204.html

# create a file
write.table(iris,"iris.csv",row.names=FALSE,sep=",",quote=FALSE)


# this does not work
# has the syntax changed or  is there a mistake in my usage?
# the line from the post above is:
#  read.csv.sql("myfile.csv, sql = "select * from file 2000, 1000")

library(sqldf)
read.csv.sql("iris.csv", sql = "select * from file 5, 5")

# this works
# but i would like to keep the header

 read.csv.sql("iris.csv", sql = "select * from file limit
5",skip=5,header=FALSE)

# thanks


> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] tcltk     stats     graphics  grDevices utils     datasets
methods   base

other attached packages:
[1] sqldf_0.4-2           chron_2.3-42          gsubfn_0.5-7
proto_0.3-9.2         RSQLite.extfuns_0.0.1 RSQLite_0.9-4
DBI_0.2-5             myfunctions_1.0

loaded via a namespace (and not attached):
[1] tools_2.13.1



More information about the R-help mailing list