[R] Sampling from a Postgres database
Bart Joosen
bartjoosen at hotmail.com
Fri Jan 15 10:49:37 CET 2010
One way could be to first select only the unique ID's, sample this and then
select only the relevant records:
strQuery = "SELECT ID from tblFoo;"
IDs <- sqlQuery(channel, strQuery)
sample.IDs <- sample(IDs,10)
strQuery = paste("SELECT ID from tblFoo WHRE ID IN(", sample.IDs, ");")
IDs <- sqlQuery(channel, strQuery)
Bart
christiaan pauw-2 wrote:
>
> Hi Everybody
>
> Is there a way in which one can use the RPostgreSQL package to take a
> sample
> from a table in Postgres database without having to read the whole table
> into R
>
> regards
> Christiaan
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>
--
View this message in context: http://n4.nabble.com/Sampling-from-a-Postgres-database-tp1014506p1014638.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list