Function for constructing relative paths in R? -


is there similar make.path.relative(base.path, target.path)?

i want convert full paths relative paths given base path (like project's directory).

similar, shorter:

make.path.relative = function(base, target) {   common = sub('^([^|]*)[^|]*(?:\\|\\1[^|]*)$', '^\\1/?', paste0(base, '|', target))    paste0(gsub('[^/]+/?', '../', sub(common, '', base)),          sub(common, '', target)) }  make.path.relative('c:/home/adam', 'c:/home/adam/tmp/r') #[1] "tmp/r"  make.path.relative('/home/adam/tmp', '/home/adam/documents/r') #[1] "../documents/r"  make.path.relative('/home/adam/documents/r/project', '/home/adam/minetest') #[1] "../../../minetest" 

voodoo regex comes from here.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -