Re: [R] Replace sub string

2012-03-22 Thread Ajay Askoolum
Thanks.

1. For consistency: I am using / everywhere else in my script.

2. For ease of use: I am passing the string to a client application (using 
rcom) where it is easeir to handle / than \\.





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

Ivan
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Replace sub string

2012-03-22 Thread Ivan Calandra

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.calan...@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@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.




__
R-help@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.


[R] Replace sub string

2012-03-22 Thread Ajay Askoolum
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@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.