final R file