[R] inner join sqldf

Gabor Grothendieck ggrothendieck at gmail.com
Mon Mar 15 15:49:27 CET 2010


Its unlikely that the inner join is what you want. prochi has only 5
levels so the result is going to be enormous.  In the second statement
you are trying to union incompatible tables.  Get an introductory book
on SQL and read up on how it works.

On Mon, Mar 15, 2010 at 10:39 AM, Newbie19_02 <nvanzuydam at gmail.com> wrote:
>
> Dear Gabor,
>
> require(sqldf)
>
> file(description="http://n4.nabble.com/file/n1593282/test_sql_psd.txt",
> open="")
> file(description="http://n4.nabble.com/file/n1593282/test_sql_tsf.txt",
> open="")
>
> test_sql_psd <-
> read.table(file="http://n4.nabble.com/file/n1593282/test_sql_psd.txt",
> header=TRUE, sep="\t", dec=".", na.strings="NA",
> check.names=TRUE, quote= "\"'")
>
>
> test_sql_tsf
> <-read.table("http://n4.nabble.com/file/n1593282/test_sql_tsf.txt" ,
> header=TRUE, sep="\t", dec=".", na.strings="NA", check.names=TRUE, quote=
> "\"'")
>
>
>
>
> test_sql_innerjoin <- sqldf("select * from test_sql_psd inner join
> test_sql_tsf
> on test_sql_psd.prochi=test_sql_tsf.prochi")
>
> Please note that in my previous email I said that I had used union and it
> had worked.  In fact it did not.
>
> test_sql_union<-sqldf("select * from test_sql_tsf union select * from
> test_sql_psd")
> did not work because of the following error:  Error in
> sqliteExecStatement(con, statement, bind.data) :
>  RS-DBI driver: (error in statement: SELECTs to the left and right of UNION
> do not have the same number of result columns)
>
>
> Please let me know if this works otherwise I'll amend the code again.
>
> Thanks,
> natalie
> --
> View this message in context: http://n4.nabble.com/inner-join-sqldf-tp1593282p1593451.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list