2 Replies Latest reply on Dec 6, 2017 2:45 AM by Jennifer Jennings

    Tableau with R

    Jennifer Jennings



      I am working on a project where I have a slightly strange request. I for each day I have an hourly reading, if the daily average is above a limit (set using a user parameter) then they want to see the 24 readings that make up that day. Then I needed to work out how many of the 24 readings would have to be excluded to being the day back to the daily average.

      I wrote some R code which is working in R but when I try to put it into Tableau I get an error. "Error in while (x_bar > test_mean) { : missing value where TRUE/FALSE needed"


      The calculation i am using is :



      get_overlimit <- function(nums, mean)

        { test_mean = mean

          my_nums = nums

          original = nums

          temp = c()


          # Get mean

          x_bar = mean(original)


          if (x_bar > test_mean){

              while (x_bar > test_mean){

                    temp = c(temp,max(my_nums))

                    my_nums = my_nums[my_nums != max(my_nums)]

                    x_bar = mean(my_nums)





          return (0)







           dataset  = .arg1

           limit = .arg2[1]


      get_abatment(dataset, limit)


      ",sum([readings]), [Daily Limit])


      Any help or insight would be really appreciated. Thanks