[R] Passing arguments to SQL Query in R

guruappa guruappa at gmail.com
Thu Jul 26 10:59:37 CEST 2012


Hello all,

I am a newbie at R, with some experience in PERL.

I have a database table that contains the following data:
Name      | Score
======= | =====
Sachin T  | 25
Sachin T  | 53
Sachin T  | 57
Sachin T  | 34
Rahul D   | 38
Rahul D   | 31
Rahul D   | 53
Ricky P   |  7
Ricky P   | 45
Ricky P   | 27
Ricky P   | 17
Ricky P   | 86
Ricky P   | 48
Jacques K | 23
Jacques K | 86
Jacques K | 32

I want the summary data as below:

Name | Avg Score
Jacques K|47.00
Rahul D|40.67
Ricky P|38.33
Sachin T|42.25

Currently, I am trying to pass the name of the person as an argument in a
sql query by breaking the query into parts, and then concatenating the query
string.  Of course, the scheme is not working.

I want a query as below:
SELECT NAME, SCORE FROM PLAYER_SCORE_TBL where NAME = ?

Then I can pass the parameters like we do in PERL.

If there is an alternative to the whole scheme, that would be wonderful.  a
way that would just take the whole table, and provide pivot table like
solution.

Thanks in advance,
Guruppa Padsali.




--
View this message in context: http://r.789695.n4.nabble.com/Passing-arguments-to-SQL-Query-in-R-tp4637899.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list