Your problem is that you are aggregating all your data before you send it to R.
If you go into the analysis menu, and uncheck Aggregate Measures or add a RowID to your data and put that row into your Viz as continuous dimension, you won't have that problem.
Notice, that you can not add a RowID as a discrete dimension because then it would partition or data by the RowID and send each row to your R calculation separately.
To debug problems like this in the future, you can run R.exe from a console window, call Rserve() and then add print statements to the scripts embedded in your calculations.
This way you can print intermediate results which will appear in your console window.
Your problem becomes obvious when you print.arg2 and see a single average of all your MaxSignon values.
I've added a super simple example.
The data has just four rows with the 2nd and 4th both being for Participant ID 2.
The average of Max Signon with all rows averaged by Tableau and then averaged again by your script is 12.5.
The average of Max Signon computed by your script with the fourth duplicate row deleted is 10.
solutionV10.twbx 14.1 KB
Thank you very much Scott,
Scott could you please reload the sample data set again?
There is some issue in opening the file,
Oops, the data wouldn't be the issue since it is a packaged workbook.
But, I accidentally loaded a workbook from a version that you don't have.
I'll recreate it as version 10.something
Thank you very much Scott for this. Also,I s there any way I could display only one value(10.00) rather than displaying 4 values?