A quick and easy way to convert an R data.frame to a Tableau .tde or .hyper Extract.
- This package uses R package reticulate as an interface to use my co-authored Python package pandleau. In order to use the package, you must install Python. Anaconda Distribution is recommended. You can download either Python 2 or 3.
- After installation of Python, following the instruction in the
Prerequisites
andInstalling
section of pandleau to install TableauSDK(or Extract API 2.0, depends on whether you want to output as .tde or .hyper format) and pandleau itself.
Once installing prerequisites is done, install the package from this repository:
install.packages("devtools")
devtools::install_github("zhiruiwang/RTableau")
The most simple example is output iris dataset into .tde or .hyper format:
library(RTableau)
write_tableau(iris,"iris.tde")
Another example that involves setting spatial column and add index:
I grabbed the following Brazil flights data off of kaggle for this example: https://www.kaggle.com/microtang/exploring-brazil-flights-data/data.
library(tidyverse)
library(RTableau)
# Read in the data and select first 1000 rows
example_df <- read_csv("BrFlights2.csv")
example_df <- slice(example_df,1:1000)
# Set up a spatial column as `POINT (Lon Lat)` format
example_df <- example_df %>%
mutate(SpatialDest = paste0("POINT (",round(LongDest,6)," ",round(LatDest,6),")"))
# Write .tde or .hyper Extract!
write_tableau(example_df,"BrFlights.tde","SpatialDest",add_index = T)
- Zhirui (Jerry) Wang - zhiruiwang
This project is licensed under the MIT License - see the LICENSE.md file for details