[R] sqldf syntax, selecting rows, and skipping

David Winsemius dwinsemius at comcast.net
Thu Sep 29 16:41:44 CEST 2011


On Sep 29, 2011, at 10:06 AM, Juliet Hannah wrote:

> 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")

You didn't read to the end of that thread. The two errors above were  
corrected.

>
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list