Удивительно, что в R нет структуры типа «$ 0»! Вы можете сделать это с помощью вызова system () для сценария bash, написанного в R:
write.table(c("readlink -e $0"), file="scriptpath.sh",col=F, row=F, quote=F)
thisscript <- system("sh scriptpath.sh", intern = TRUE)
. Затем просто разделите имя scriptpath.sh для other.R
splitstr <- rev(strsplit(thisscript, "\\/")[[1]])
otherscript <- paste0(paste(rev(splitstr[2:length(splitstr)]),collapse="/"),"/other.R")