fix issues in r script