delimited quoted string for query criteria

Hi Stringr Tidyverse
I have to create delimited quoted strings for filtering in query writing.
I have a number of DRG (diagnosis related groups) to put as criteria.
SQL needs them as delimited quoted strings as in dplyr and many of R packages.
For example,
CostingDataset_Encounter.CostingDataset_Id IN (38)
--(4, 11, 12, 16, 18, 20, 21, 26))
Ref_Drg.Code in ('h09z', 'h08a', 'h08b', 'h08c') where comma is needed among quoted strings.

It is not hard for hard coding for a few but will be really time consuming.
I tried the following base R paste0() but there are no comma among quoted strings.

States_Abb_20<-c("AK", "AL", "AR", "AS", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "GU", "HI", "IA", "ID", "IL", "IN", "KS", "KY")


I hope stringr will be able to help.
Thank you.

I am not sure I understand your requirements correctly. Is this what you need?

States_Abb_20<-c("AK", "AL", "AR", "AS", "AZ", "CA", "CO", "CT", "DC", 
                 "DE", "FL", "GA", "GU", "HI", "IA", "ID", "IL", "IN", 
                 "KS", "KY")
paste0("'",States_Abb_20,"'",collapse = ",")
#> [1] "'AK','AL','AR','AS','AZ','CA','CO','CT','DC','DE','FL','GA','GU','HI','IA','ID','IL','IN','KS','KY'"

Created on 2022-10-06 with reprex v2.0.2

@FJCC thank you very much for your prompt response and solution. excellent.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.