[R] Replace sub string

Ivan Calandra ivan.calandra at u-bourgogne.fr
Thu Mar 22 13:43:19 CET 2012


Hi,

See ?gsub
But why would you do that? Both / and \\ are valid in a path, aren't they?

Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra


Le 22/03/12 13:35, Ajay Askoolum a écrit :
> Given:
>
>> filename<-paste(tempdir(),"\\","myfile.txt",sep="");
>> sub("\\\\","/",filename);
> [1] "C:/DOCUME~1\\AJAYAS~1\\LOCALS~1\\Temp\\Rtmp2f270T\\myfile.txt"
>
>
> Note: Only the first occurence of \\ is replaced. What is the syntax for replacing every occurence?
>
> Thanks.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list