R and Tableau Integration Calculated Field - Mann-Kendall Test

I am trying to detect a monotonic increase or decrease in the rate of ED visits over a 6 month time period (using monthly rates). I would like to see the p-value in the tool-tip when hovering over the point in a line graph on a dashboard. Could someone assist with the creation of a calculated field to achieve this? First, I am trying to figure this out using sample data of yearly rates, but I keep getting this error in tableau:

An error occurred while communicating with data source 'Analytics Extension' 
Error Code: 8AD4B404. The result returned by the SCRIPT function is of an 
unexpected type.

I get the same error when using SRIPT_REAL. Here is what I have typed for a calculation in Tableau:

SCRIPT_INT(

library(Kendall);
x - .arg1;
result - MannKendall(x)$p.value;
, 
AVG([Rate])
) 

I am able to successfully run the test in R. Any suggestions on how to adjust this calculated field so that it works in Tableau would be helpful.

Topic tableau r

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.