1. As I noticed in all examples when they indicate data they write like this: BMI as bmi. I am not sure if it matters but if there are no other ideas I would try.
2. For aggregations you need to use aggregate versions of the function:
R.ScriptAggr('mean(q$BMI);' BMI as BMI)
3. You need to be careful when using Str version of the function and passing numerical data. Maybe you could use:
R.ScriptEvalExStr('N', 'source(q$RSource);', RSource as RSource)