2010-10-26 4 views
2

en tant que titre, je travaille sur un certain gregexpr dans R maintenant, j'ai besoin de chercher quelque chose commencer par un point, donc j'ai besoin d'utiliser "." (sans citation), mais R continue à dire que c'est une évasion non reconnue. Que puis-je faire?comment coller le "backslash-dot" (.) Combo dans R?

Merci!

Répondre

9

Vous devez échapper à l'antislash.

> string <- c("foo","ba.r") 
> grep("\.",string) 
Error: '\.' is an unrecognized escape in character string starting "\." 
> grep("\\.",string) 
[1] 2