1 Reply Latest reply on Dec 2, 2013 3:41 PM by Cristian Vasile

    Having trouble wrapping mind around R integration into Tableau..


      Alright so I don't completely understand the limitations as they currently stand when it comes to using R within Tableau.


      I just want to see if something like this is possible.


      I am trying to calculate the mode of a something using R in Tableau. Let's assume teradatatable is a data source connected via teradata.


      itemids <- unique(teradatatable[,c("ITEM_ID")])

      result <- as.data.frame(rbind(c("1",2)))

      colnames(result) <- c("item_id", "mode_price")

      result[,c("item_id")] <- as.character(result[,c("item_id")])

      result[,c("mode_price")] <- as.numeric(as.character(result[,c("mode_price")]))

      #that was just initializing the table

      n <- length(unique(teradatatable[,c("ITEM_ID")])

      for (i in 1:n) {

        subsetsku <- teradatatable[teradatatable[,c("ITEM_ID")] == itemids[i],]

        mode <- names(sort(-table(subsetsku[,c("PRICE")])))[1]

        result <- rbind(result,c(itemids[i],mode))



      result is a two column table which has item ID and mode price with all of the unique item ids represented.


      For an example data set, lets just say it's a bunch of item ids, many repeating, with different price points some price points repeat.


      My end goal is that I want to be able to push item id data and mode price data onto a view in Tableau. They can be aggregated as long as I can use average and it will bring it back down to the same mode price.

      I ultimately want to be able to make a view on Tableau, something like |Item ID|Price(Mode)|Sales|Qty| etc..


      My current R code works fine in R, but how would I go about transitioning it into a Tableau friendly format?