Saturday, January 10, 2015
Tableau dashboard text Link
A trick learned from Tableau Friction:
Replace text node in .twb file with new link node.
Example:
<run auto-url='true' fontcolor='#d8504c' hyperlink='tabdoc:load-url url=&quot;http://www.google.com&quot;'>This is a link to Google</run>
Source:
Dashboard Text Links - Adding and Customizing, no Worksheets Needed
Test change detect and breakout detect togeter
Two awesome posts in the first week of 2015.
Put them together:
Updates
Put them together:
Updates
Monday, December 29, 2014
SQL script to profile data in table
Script below can be useful to produce a summary of columns in a table.
When we get a new data sources without sufficient document, this script can help us to list the number of NULLs and distinct values, as well as to list the top 50 unique values of a column.
Please download the SQL script: ProfileTable.sql
Use stored procedure in Tableau to optimize consultant practice
The typical workflow of consulting service can be labor-intensive and error-prone. We need to copy data among applications, set up calc sheet in Excel, snip Tableau screenshot, and finally to make the slides reflect the correct information scattered in modeling tools, database, and spread sheets.
What if we simplify the workflow by removing some applications, say, Excel.
So, here is a proposal to move the calculation in Excel into SQL database with the feature of stored procedure support in Tableau 8.1 and later.
What if we go even further, say, replace PowerPoint slides with Tableau Story Points.
What if we simplify the workflow by removing some applications, say, Excel.
So, here is a proposal to move the calculation in Excel into SQL database with the feature of stored procedure support in Tableau 8.1 and later.
What if we go even further, say, replace PowerPoint slides with Tableau Story Points.
Friday, June 21, 2013
Count frequency of factor column
Name: frqTable
Scenario: Want exchange data to Excel, or do the long tail fit
Code:
frqTable <- function(aFactorCol, aColName, aIsDecs="TRUE"){
ret <- as.data.frame(table(aFactorCol))
colnames(ret) <- c(aColName,'frq')
ret <- ret[order(ret$frq,decreasing=aIsDecs),]
rownames(ret) <- NULL
return (ret);
}
Scenario: Want exchange data to Excel, or do the long tail fit
Code:
frqTable <- function(aFactorCol, aColName, aIsDecs="TRUE"){
ret <- as.data.frame(table(aFactorCol))
colnames(ret) <- c(aColName,'frq')
ret <- ret[order(ret$frq,decreasing=aIsDecs),]
rownames(ret) <- NULL
return (ret);
}
Refactor: Drop unused level of a factor variable
Name: refactor
Scenario: After subset a data frame, the factor columns may include 0 frequncy levels
Related:
1. drop = TRUE, e.g. problem.factor <- problem.factor[, drop = TRUE]
References:
http://r.789695.n4.nabble.com/Refactor-all-factors-in-a-data-frame-td826749.html
http://www.r-bloggers.com/data-types-part-3-factors/
http://rwiki.sciviews.org/doku.php?id=tips:data-manip:drop_unused_levels
Code:
refactor <- function (aDf){
cat <- sapply(aDf, is.factor);
aDf[cat] <- lapply(aDf[cat], factor);
}
Scenario: After subset a data frame, the factor columns may include 0 frequncy levels
Related:
1. drop = TRUE, e.g. problem.factor <- problem.factor[, drop = TRUE]
2. drop.levels() function in gdata package
References:
http://r.789695.n4.nabble.com/Refactor-all-factors-in-a-data-frame-td826749.html
http://www.r-bloggers.com/data-types-part-3-factors/
http://rwiki.sciviews.org/doku.php?id=tips:data-manip:drop_unused_levels
Code:
refactor <- function (aDf){
cat <- sapply(aDf, is.factor);
aDf[cat] <- lapply(aDf[cat], factor);
}
Wednesday, June 19, 2013
Methods to save data frame in file in R
When you try to "save" your data set in a data frame object in R, you have several options:
|
Method
|
Pro
|
Con
|
Funcitons
|
|
Image the object in binary format
|
Fast, can keep object name and other environment information
|
R specific
|
save(df, file= "filename")
rm(df)
load("filename", .GlobalEnv)
|
|
Save in coded text
|
Full information, e.g. data mode
|
Size is big, can not exchange with other software
|
dump(c("df"),"filename")
newDf = source(“filename")$value
|
|
Export to plain text
|
Human readable, and software exchangeable
|
May need to recast R types when read in
|
write.table()
read.table()
|
|
Export to other format
|
Software specific
|
Software specific
|
Write.X()
Read.X(), where X can be spss, sas,csv, excel
|
Subscribe to:
Posts (Atom)
