
1. Re: R Integrationpass fixed argument to Rtrim value for mean
Glenn Kuly Jan 18, 2019 6:38 AM (in response to Glenn Kuly)Updating my thread, Trimmed Mean: SCRIPT_REAL("mean(.arg1, trim = 0.05)", AVG([Response])) does actually work, as long as response ID number in the view (which of course shows all rows for Response).
Trying to figure out a way of using an LOD expression (include) for arg1 so that i can show the average alone (without all individual values in the view). So far no success.
 Glenn

2. Re: R Integrationpass fixed argument to Rtrim value for mean
Jim Dehner Jan 18, 2019 7:17 AM (in response to Glenn Kuly)Hi Glenn
the interface with R and with Python works through table calculations so you would have to do it like the attached
first I calculated the fixed avg by state
then the single fixed overall value
then dropped it into a lookup function to make it into a table calc
then went out to R
to get this
its the long way around but maybe it will meet your need
Jim
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.

rtrim example.twbx 2.3 MB


3. Re: R Integrationpass fixed argument to Rtrim value for mean
Glenn Kuly Jan 18, 2019 7:43 AM (in response to Jim Dehner) 
4. Re: R Integrationpass fixed argument to Rtrim value for mean
Jim Dehner Jan 18, 2019 8:02 AM (in response to Glenn Kuly)I don't know  that wasn't the question you asked
You have to work from a table calculation  table calculations are at the bottom of the Order of operation so any LOD is executed above the table calculations
also any top / bottom 10 will depend on a table calculation  see below it seems to calculate the avg of the 10 _ I don't think that is what you meant
Jim
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.

5. Re: R Integrationpass fixed argument to Rtrim value for mean
Glenn Kuly Jan 18, 2019 10:54 AM (in response to Jim Dehner)Apologies for the misunderstanding, I'm looking to use the mean function in R, with an argument for trim to eliminate the highest and lowest X% of values in a dataset where there are extreme outliers.
So if i use the following calculated field in your workbook for trimmed mean (5%) of average sales,
R Timmed 2:
SCRIPT_REAL(
"mean(.arg1, trim = 0.05)",
AVG([Sales])
)
the result is $242:
The problem is trying to show the total only (without rows for states).
I know that there is a technique (developed here http://drawingwithnumbers.artisart.org/trimmeanintableau/) for calculating trimmed mean within Tableau using Rank_Unique, but it won't work where the data is highly skewed.
 Glenn