0

I'm trying to concatenate two strings. The first string should look like the following:

a <- paste("//*/a[@href = 'abcd1234.cfmcyc_dt=",eopm, "&orig_id=1234']",sep="")
> a 
 [1] "//*/a[@href = 'abcd1234.cfmcyc_dt=20160731&orig_id=1234']"

Then I want to add the second string which is just a closing parentheses like so:

b <- ")"
c <- noquote(b)
[1] )

I try the following but the double quotes gets moved to the end:

paste(a,c)
"//*/a[@href = 'abcd1234.cfmcyc_dt=20160731&orig_id=1234'])"

I want it to look like this:

"//*/a[@href = 'abcd1234.cfmcyc_dt=20160731&orig_id=1234']")

I tried work with escaping the quotes but I can't seem to get it.

d84_n1nj4
  • 1,712
  • 6
  • 23
  • 40
  • 1
    Why are you doing this? The outer parentheses are only shown because it's a character string. They are not really there. `noquote` is not going to help, btw. If you are trying to assemble a function call with strings, stop and do it the right way. – Rich Scriven Aug 24 '16 at 16:05
  • If the answers indeed helped you resolve the issue, please select one and close the question. If there's anything else you seek, you can update the question details. We would be happy to answer it. :) – Pj_ Aug 24 '16 at 17:01

2 Answers2

1

Try doing this way:

a <- paste("//*/a[@href = 'abcd1234.cfmcyc_dt=", 'eopm' , "&orig_id=1234']",sep="")
b <- '")'
c <- noquote(b)

Result

paste(a, c)
[1] "//*/a[@href = 'abcd1234.cfmcyc_dt=eopm&orig_id=1234'] \")"
Pj_
  • 824
  • 6
  • 15
-1

Try this:

eopm <- 20160731    
a <- paste0("//*/a[@href = 'abcd1234.cfmcyc_dt=",eopm, "&orig_id=1234']")
b <- '")'
c <- noquote(b)
noquote(paste0('"',a,c))

Result:

> noquote(paste0('"',a,c))
[1] "//*/a[@href = 'abcd1234.cfmcyc_dt=20160731&orig_id=1234']")
Erick Díaz
  • 98
  • 2
  • 15
  • According to what you have posted, your solution doesn't really produces the right answer. – Pj_ Aug 24 '16 at 16:15
  • I edited the answer because i forgot to copy the set of the variable eopm, but it does produce the result – Erick Díaz Aug 24 '16 at 16:41