The path is not in correct form. It should either be "d:\\temp\\aaa.jpg" or "d:/temp/aaa.jpg". So it is interpreted by R that your path contains "\t" and "\a" rather than a directory slash.
pacifly 发表于 2013-1-4 03:23
"问题1:如何根据d:\temp\aaa.jpg 得到d:/temp/aaa.jpg ?"
The path is not in correct form. It should either be "d:\\temp\\aaa.jpg" or "d:/temp/aaa.jpg".
So it is interpreted by R that your path contains "\t" and "\a" rather than a directory slash.
"问题2:如何根据d:/temp/aaa.jpg 得到上一级目录d:/temp/?"
a="d:/temp/aaa.jpg"
regmatches(a, regexpr(".+/",a))
no way to automate this because R can't parse the string correctly in such case. Suppose change your original path to "d:\temp\caa.jpg", this will not be valid in R (you can try print it in R console), because "\c" is not a recognized escape. Your original path was just lucky to go through R because "\t" and "\a" happen to be those recognized ones.