[R] writes R output to stdout and stderr