2013-02-19 6 views
10

Ho bisogno di sfuggire alle virgolette nel seguente esempio e R restituisce:Doppia non quotes sfuggito nella R

xx<-"the road is 'rocky all \"the\" way'" 
xx 

[1] "the road is 'rocky all \"the\" way'" 

La stringa finale dovrebbe contenere sia il le virgolette singole e

the road is 'rocky all "the" way' 

Come posso ottenere questo risultato?

risposta

17

L'hai già raggiunto. È solo che print() sfugge alle virgolette quando li visualizza:

R> xx <- "the road is 'rocky all \"the\" way'" 
R> cat(xx) 
the road is 'rocky all "the" way' 
+0

come creare un vettore di caratteri di questo xx? –

+1

@MuhammadUsmanSaleem L'oggetto 'xx' è già un vettore di caratteri: '> xx <- "la strada è 'tutto roccioso \" il \ "modo'" > classe (xx) [1] "carattere" ' – Robert

+0

@ Robert questo stampa semplicemente i doppi qout tra virgolette. ** come posso rimuovere '\ così che posso ottenere" "la strada è rock tutto" il "modo" "'? –