Hi Dennis and Ista,
Thanks a lot.
The solution is great.

Actually I am trying to do bulk select from database and it require where
clause in this form only.

inpData = read.csv('./rugitSrc/testFile.csv', header= TRUE)
idList = as.character(inpData[,1])
1> idList
[1] "rc_AI104113_at"   "rc_AI178259_f_at" "rc_AI179134_i_at"
"rc_AI179134_f_at"  "rc_AI104113_at"   "rc_AA819429_f_at"

strsep2 <- sapply(idList, function(x) paste("'", x, "'", sep = ""))
idListWithSep = paste(strsep2, collapse = ',')
1> idListWithSep
[1]
"'rc_AI104113_at','rc_AI178259_f_at','rc_AI179134_i_at','rc_AI179134_f_at','rc_AI104113_at','rc_AA819429_f_at'"

query = paste("select * from ", tn, " where name IN (" , idListWithSep ,  ")
", sep ='')
1> query
[1] "select * from rat_rn4_affy_RG_U34Cprobe_fasta where name IN
('rc_AI104113_at','rc_AI178259_f_at','rc_AI179134_i_at','rc_AI179134_f_at','rc_AI104113_at','rc_AA819429_f_at')
"
res <- dbSendQuery(con, query)
queryResult <- fetch(res, n = -1)

I am able to perform bulk query now in the database.

Thanks again.
Fahim




On Wed, Mar 9, 2011 at 4:49 PM, Dennis Murphy <djmu...@gmail.com> wrote:

> Hi:
>
> I'm not quite sure what you have in mind, but...
>
> Input data strdat.txt:
>
> probeID
> rc_AI104113_at
> rc_AI178259_f_at
> rc_AI179134_i_at
> rc_AI179134_f_at
> rc_AI104113_at
> rc_AA819429_f_at
>
> strg <- paste(scan('strdat.txt', what = '', skip = 1), collapse = ',')
> strg
> [1]
> "rc_AI104113_at,rc_AI178259_f_at,rc_AI179134_i_at,rc_AI179134_f_at,rc_AI104113_at,rc_AA819429_f_at"
>
> # Try to get single quotes surrounding each string
> strsep <- paste(scan('strdat.txt', what = '', skip = 1))
> Read 6 items
> > strsep
> [1] "rc_AI104113_at"   "rc_AI178259_f_at" "rc_AI179134_i_at"
> "rc_AI179134_f_at"
> [5] "rc_AI104113_at"   "rc_AA819429_f_at"
> strsep2 <- sapply(strsep, function(x) paste("'", x, "'", sep = ""))
> paste(strsep2, collapse = ',')
> [1]
> "'rc_AI104113_at','rc_AI178259_f_at','rc_AI179134_i_at','rc_AI179134_f_at','rc_AI104113_at','rc_AA819429_f_at'"
>
> HTH,
> Dennis
>
>
> On Wed, Mar 9, 2011 at 12:35 PM, Fahim Mohammad <fahim...@gmail.com>wrote:
>
>> I have a file with a data in columnar format like below:
>>
>> probeID
>> rc_AI104113_at
>> rc_AI178259_f_at
>> rc_AI179134_i_at
>> rc_AI179134_f_at
>> rc_AI104113_at
>> rc_AA819429_f_at
>>
>> How can I rewrite it in the  format below:
>> 'rc_AI104113_at', 'rc_AI178259_f_at', 'rc_AI179134_i_at',
>> 'rc_AI179134_f_at', 'rc_AI104113_at', 'rc_AA819429_f_at'
>>
>>
>> Is there any function to do this. I can do it by using iterative paste but
>> I just want to avoid it for efficiency reason as number of probes is very
>> high.
>>
>> Thanks
>>
>> --Fahim
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@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.
>>
>
>


-- 
Fahim Mohammad
Ph. D. Student
Bioinforformatics Lab
University of Louisville
Louisville, KY, USA
Ph:  +1-502-409-1167

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to