Re: [R] How to convert "c:\a\b" to "c:/a/b"

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Wed 29 Jun 2005 - 13:45:36 EST

          Close, but does not work generally with RGui 2.1.1 patched, Windows XP:

 > unback(x="n\o")
[1] "no"

          I'm also unable to parse "echo", suggested by Ten Harding and Henrik Bengtsson:

 > echo D:/spencerg/statmtds/R/Rnews> tmp.txt Error: syntax error
 > echo cat(gsub("\\\\", "/", readLines("tmp.txt"))) | R --slave Error: syntax error

          Earlier today, Sundar Dorai-Raj helped me with the following:

 > (File0 <- file.choose())
[1] "D:\\spencerg\\dataPOWER\\stats\\Tukey\\Boxplot_missing_Tukey2.txt"  > strsplit(File0, "\\\\")

[[1]]
[1] "D:"                         "spencerg"
[3] "dataPOWER"                  "stats"
[5] "Tukey"                      "Boxplot_missing_Tukey2.txt"

 > fp. <- strsplit(File0, "\\\\")[[1]]
 > (path <- paste(fp.[-length(fp.)], collapse="/")) [1] "D:/spencerg/dataPOWER/stats/Tukey"
 > setwd(path)
 > getwd()
[1] "D:/spencerg/dataPOWER/stats/Tukey"
 > File <- fp.[length(fp.)]
 > File
[1] "Boxplot_missing_Tukey2.txt"

          Thanks to everyone who has contributed (or even read) this thread. I'm confident that a better method exists.

	  Best Wishes,
	  Spencer Graves
	

David Duffy wrote:

> I couldn't resist adding a more literal answer
>
> unback <- function(x) {
> chars <- unlist(strsplit(deparse(x),""))
> chars <- chars[-c(1,length(chars))]
> paste(gsub("\\\\","/",chars),collapse="")
> }
>
> unback("\n")
>
>
> | David Duffy (MBBS PhD) ,-_|\
> | email: davidD@qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
> | Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
> | 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves@pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jun 29 13:52:57 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:06 EST