I want to do two thing:
1) I want to create a character string with a double quote inside. An example in R would look like follows:
x <- 'vjghvbh"kljnj"kjbn"jk'
[1] "vjghvbh\"kljnj\"kjbn\"jk"
Question 1: How could I create such a character string without the backslash inside?
I tried to use gsub()
, but unfortunately that didn't work. I also found some sources, which suggested cat()
, but that just prints my character, but does not store it in x
.
2) Let's assume that I solved Question 1. Then my character would look like follows:
[1] "vjghvbh"kljnj"kjbn"jk"
Now I need to find the positions of the double quotes. Based on this thread I tried gregexpr()
. However, this also did not work, since I was not able to specify the pattern
.
Question 2: How could I find the position of the double quotes within my character string?
The result in R should look like this:
[1] 8 14 19