How to change ' in " in my list of names

Hello,
this is my list of genes:
Genes_LIST = c ("CXCL8,CCL5,CCR3,CCR4,CCR5,CXCL12,ACKR3,CXCR4,CCR7,CCL19,CCL21,CCL13,CCR2,CXCR6,CXCL16,ACKR4,CCL25,CXCR3,CXCL9,XCL10,CXCL11,CXCL13,CXCR5,CXCR2,CXCL5,CXCL2,CXCL1,CXCL3,PPBP,CXCL6,PF4,CCR8,CCR1,CCL16,ACKR2,CCL7,CCL3,CCL3L1,CCL17,CCL11,CCL2,CCL22,CCL4,CCR9,CCR6,CCL20,CXCR1,CCR10,CCL28,CCL27,CX3CL1,CX3CR1,XCR1,XCL2,XCL1,CCRL2,CCL1"),

I want to have all my words like this "CXCL8", "CCL5", "CCR3" etc etc

So I did Genes_LIST <-gsub("," , " ',' ", Genes_list)
paste(Genes_LIST)

and I have obtained
[1] "CXCL8 ',' CCL5 ',' CCR3 ',' CCR4 ',' CCR5 ',' CXCL12 ',' ACKR3 ',' CXCR4 ',' CCR7 ',' CCL19 ',' CCL21 ',' CCL13 ',' CCR2 ',' CXCR6 ',' CXCL16 ',' ACKR4 ',' CCL25 ',' CXCR3 ',' CXCL9 ',' XCL10 ',' CXCL11 ',' CXCL13 ',' CXCR5 ',' CXCR2 ',' CXCL5 ',' CXCL2 ',' CXCL1 ',' CXCL3 ',' PPBP ',' CXCL6 ',' PF4 ',' CCR8 ',' CCR1 ',' CCL16 ',' ACKR2 ',' CCL7 ',' CCL3 ',' CCL3L1 ',' CCL17 ',' CCL11 ',' CCL2 ',' CCL22 ',' CCL4 ',' CCR9 ',' CCR6 ',' CCL20 ',' CXCR1 ',' CCR10 ',' CCL28 ',' CCL27 ',' CX3CL1 ',' CX3CR1 ',' XCR1 ',' XCL2 ',' XCL1 ',' CCRL2 ',' CCL1"

But I cannot tell R to change ' in ".
Do you know how to do it, please?
Thanks


  Genes_LIST = c("CXCL8,CCL5,CCR3,CCR4,CCR5,CXCL12,ACKR3,CXCR4,CCR7,CCL19,CCL21,CCL13,CCR2,CXCR6,CXCL16,ACKR4,CCL25,CXCR3,CXCL9,XCL10,CXCL11,CXCL13,CXCR5,CXCR2,CXCL5,CXCL2,CXCL1,CXCL3,PPBP,CXCL6,PF4,CCR8,CCR1,CCL16,ACKR2,CCL7,CCL3,CCL3L1,CCL17,CCL11,CCL2,CCL22,CCL4,CCR9,CCR6,CCL20,CXCR1,CCR10,CCL28,CCL27,CX3CL1,CX3CR1,XCR1,XCL2,XCL1,CCRL2,CCL1")

 (Genes_LIST2 <-paste0('"',gsub(',','" , "', Genes_LIST),'"'))
  
cat(Genes_LIST2)

Hello,
thanks,
but if I do like that I have this:
"CXCL8 '" , "' CCL5 '" , "' CCR3 '" , "' CCR4 '" , "' CCR5 '" , "' CXCL12 '" , "' ACKR3 '" , "' CXCR4 '" , "' CCR7 '" , "' CCL19 '" , "' CCL21 '" , "' CCL13 '" , "' CCR2 '" , "' CXCR6 '" , "' CXCL16 '" , "' ACKR4 '" , "' CCL25 '" , "' CXCR3 '" , "' CXCL9 '" , "' XCL10 '" , "' CXCL11 '" , "' CXCL13 '" , "' CXCR5 '" , "' CXCR2 '" , "' CXCL5 '" , "' CXCL2 '" , "' CXCL1 '" , "' CXCL3 '" , "' PPBP '" , "' CXCL6 '" , "' PF4 '" , "' CCR8 '" , "' CCR1 '" , "' CCL16 '" , "' ACKR2 '" , "' CCL7 '" , "' CCL3 '" , "' CCL3L1 '" , "' CCL17 '" , "' CCL11 '" , "' CCL2 '" , "' CCL22 '" , "' CCL4 '" , "' CCR9 '" , "' CCR6 '" , "' CCL20 '" , "' CXCR1 '" , "' CCR10 '" , "' CCL28 '" , "' CCL27 '" , "' CX3CL1 '" , "' CX3CR1 '" , "' XCR1 '" , "' XCL2 '" , "' XCL1 '" , "' CCRL2 '" , "' CCL1"

Me I need to have the " at the place of ', not both. In fact I need to have a list I can run in another script, so things should be "CXCL8", "CCL5", etc and not "CXCL8 ' ", "CCL5 ' ", as I obtain if I use your kind suggestion.
Thanks a lot, by the way.

I can't reproduce what you claim in this post, the raw uncatted view of Genes_LIST2 is

 "\"CXCL8\" , \"CCL5\" , \"CCR3\" , \"CCR4\" , \"CCR5\" , \"CXCL12\" , \"ACKR3\" , \"CXCR4\" , \"CCR7\" , \"CCL19\" , \"CCL21\" , \"CCL13\" , \"CCR2\" , \"CXCR6\" , \"CXCL16\" , \"ACKR4\" , \"CCL25\" , \"CXCR3\" , \"CXCL9\" , \"XCL10\" , \"CXCL11\" , \"CXCL13\" , \"CXCR5\" , \"CXCR2\" , \"CXCL5\" , \"CXCL2\" , \"CXCL1\" , \"CXCL3\" , \"PPBP\" , \"CXCL6\" , \"PF4\" , \"CCR8\" , \"CCR1\" , \"CCL16\" , \"ACKR2\" , \"CCL7\" , \"CCL3\" , \"CCL3L1\" , \"CCL17\" , \"CCL11\" , \"CCL2\" , \"CCL22\" , \"CCL4\" , \"CCR9\" , \"CCR6\" , \"CCL20\" , \"CXCR1\" , \"CCR10\" , \"CCL28\" , \"CCL27\" , \"CX3CL1\" , \"CX3CR1\" , \"XCR1\" , \"XCL2\" , \"XCL1\" , \"CCRL2\" , \"CCL1\""

you'll see the \ symbols which show that the double quote marks are in the string and not being wrapped by r's presentation in this mode
when catted it is as you claim to wish it to be

cat(Genes_LIST2)

"CXCL8" , "CCL5" , "CCR3" , "CCR4" , "CCR5" , "CXCL12" , "ACKR3" , "CXCR4" , "CCR7" , "CCL19" , "CCL21" , "CCL13" , "CCR2" , "CXCR6" , "CXCL16" , "ACKR4" , "CCL25" , "CXCR3" , "CXCL9" , "XCL10" , "CXCL11" , "CXCL13" , "CXCR5" , "CXCR2" , "CXCL5" , "CXCL2" , "CXCL1" , "CXCL3" , "PPBP" , "CXCL6" , "PF4" , "CCR8" , "CCR1" , "CCL16" , "ACKR2" , "CCL7" , "CCL3" , "CCL3L1" , "CCL17" , "CCL11" , "CCL2" , "CCL22" , "CCL4" , "CCR9" , "CCR6" , "CCL20" , "CXCR1" , "CCR10" , "CCL28" , "CCL27" , "CX3CL1" , "CX3CR1" , "XCR1" , "XCL2" , "XCL1" , "CCRL2" , "CCL1"

which seems exactly like what you wish.
Are you running exactly my code, or have you altered it ?

Hello,
I am not very good in R. If I was running the code as you said, I obtained what I have put in the first message.

So, in effect, your code is right but I had to do like this:

Genes_list <-gsub("\s+", ",", gsub("^\s+|\s+$", "",genes))
paste(Genes_list)
[1] "CXCL8,CCL5,CCR3,CCR4,CCR5,CXCL12,ACKR3,CXCR4,CCR7,CCL19,CCL21,CCL13,CCR2,CXCR6,CXCL16,ACKR4,CCL25,CXCR3,CXCL9,XCL10,CXCL11,CXCL13,CXCR5,CXCR2,CXCL5,CXCL2,CXCL1,CXCL3,PPBP,CXCL6,PF4,CCR8,CCR1,CCL16,ACKR2,CCL7,CCL3,CCL3L1,CCL17,CCL11,CCL2,CCL22,CCL4,CCR9,CCR6,CCL20,CXCR1,CCR10,CCL28,CCL27,CX3CL1,CX3CR1,XCR1,XCL2,XCL1,CCRL2,CCL1"
Genes_LIST <-gsub("," , " ',' ", Genes_list)
paste(Genes_LIST)
[1] "CXCL8 ',' CCL5 ',' CCR3 ',' CCR4 ',' CCR5 ',' CXCL12 ',' ACKR3 ',' CXCR4 ',' CCR7 ',' CCL19 ',' CCL21 ',' CCL13 ',' CCR2 ',' CXCR6 ',' CXCL16 ',' ACKR4 ',' CCL25 ',' CXCR3 ',' CXCL9 ',' XCL10 ',' CXCL11 ',' CXCL13 ',' CXCR5 ',' CXCR2 ',' CXCL5 ',' CXCL2 ',' CXCL1 ',' CXCL3 ',' PPBP ',' CXCL6 ',' PF4 ',' CCR8 ',' CCR1 ',' CCL16 ',' ACKR2 ',' CCL7 ',' CCL3 ',' CCL3L1 ',' CCL17 ',' CCL11 ',' CCL2 ',' CCL22 ',' CCL4 ',' CCR9 ',' CCR6 ',' CCL20 ',' CXCR1 ',' CCR10 ',' CCL28 ',' CCL27 ',' CX3CL1 ',' CX3CR1 ',' XCR1 ',' XCL2 ',' XCL1 ',' CCRL2 ',' CCL1"
(Genes_LIST2 <-paste0('"',gsub(',','" , "', Genes_list),'"'))
[1] ""CXCL8" , "CCL5" , "CCR3" , "CCR4" , "CCR5" , "CXCL12" , "ACKR3" , "CXCR4" , "CCR7" , "CCL19" , "CCL21" , "CCL13" , "CCR2" , "CXCR6" , "CXCL16" , "ACKR4" , "CCL25" , "CXCR3" , "CXCL9" , "XCL10" , "CXCL11" , "CXCL13" , "CXCR5" , "CXCR2" , "CXCL5" , "CXCL2" , "CXCL1" , "CXCL3" , "PPBP" , "CXCL6" , "PF4" , "CCR8" , "CCR1" , "CCL16" , "ACKR2" , "CCL7" , "CCL3" , "CCL3L1" , "CCL17" , "CCL11" , "CCL2" , "CCL22" , "CCL4" , "CCR9" , "CCR6" , "CCL20" , "CXCR1" , "CCR10" , "CCL28" , "CCL27" , "CX3CL1" , "CX3CR1" , "XCR1" , "XCL2" , "XCL1" , "CCRL2" , "CCL1""
cat(Genes_LIST2)
"CXCL8" , "CCL5" , "CCR3" , "CCR4" , "CCR5" , "CXCL12" , "ACKR3" , "CXCR4" , "CCR7" , "CCL19" , "CCL21" , "CCL13" , "CCR2" , "CXCR6" , "CXCL16" , "ACKR4" , "CCL25" , "CXCR3" , "CXCL9" , "XCL10" , "CXCL11" , "CXCL13" , "CXCR5" , "CXCR2" , "CXCL5" , "CXCL2" , "CXCL1" , "CXCL3" , "PPBP" , "CXCL6" , "PF4" , "CCR8" , "CCR1" , "CCL16" , "ACKR2" , "CCL7" , "CCL3" , "CCL3L1" , "CCL17" , "CCL11" , "CCL2" , "CCL22" , "CCL4" , "CCR9" , "CCR6" , "CCL20" , "CXCR1" , "CCR10" , "CCL28" , "CCL27" , "CX3CL1" , "CX3CR1" , "XCR1" , "XCL2" , "XCL1" , "CCRL2" , "CCL1"

Anyway, it works, and I thank you so much!

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.