I have a script called foo.R that includes another script other.R, which is in the same directory:
foo.R
other.R
#!/usr/bin/env Rscript message(\
frame_files <- lapply(sys.frames(), function(x) x$ofile) frame_files <- Filter(Negate(is.null), frame_files) PATH <- dirname(frame_files[[length(frame_files)]])
Don't ask me how it works though, because I've forgotten :/