Reputation: 195
Example:
var<-"name"
setwd("/media/data/var")
gives an error 'cause directory "/media/data/var" does not exist, but "/media/data/name".
So, how to declare var as variable within a quoted string?
Upvotes: 3
Views: 4402
Reputation: 44525
You have to use paste
:
setwd(paste0("/media/data/",var))
Or you can use file.path
:
setwd(file.path("/media/data",var))
Upvotes: 7