> gsub("\\\\","/","D:\Prog\R\rw1090\library\cluster\libs") > [1] "D:ProgR\rw1090libraryclusterlibs" Probably not the best way, but what about escaping all the backslashes in the original string? gsub("\\\\","/","D:\\Prog\\R\\rw1090\\library\\cluster\\libs")