Created
June 9, 2016 00:31
-
-
Save sanjeevbadgeville/841cf9db041ab8c7397e257c61d1a95f to your computer and use it in GitHub Desktop.
Read a csv with multibyte characters and generate Correlation chart in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source("/Users/sanjeev/workspaces/code/work/analytics/Analysis/R/common-start.R") | |
| ################################################### drupal Site | |
| #drupal_plyrs_last30days <- read.xlsx("/Users/sanjeev/workspaces/code/work/analytics/Analysis/data/badgeville/drupal/MayPlayers.xlsx", sheetIndex = 1) | |
| #drupal_plyrs_last30days[is.na(drupal_plyrs_last30days)] <- 0 | |
| needs(readr) | |
| needs(corrgram) | |
| # Resolve invalid multibyte string at '<ff><fe>D' | |
| drupal_plyrs_last30days <- read.delim2("/Users/sanjeev/Downloads/Recognition_-_Player_Activity_Details_in_last_30_d_crosstab.csv", dec=".", fileEncoding="UCS-2LE") | |
| # Convert factors to integer | |
| colsToConvertStringsToInteger <- c(2:9) | |
| drupal_plyrs_last30days[,colsToConvertStringsToInteger] <- lapply( drupal_plyrs_last30days[,colsToConvertStringsToInteger], function(y) as.integer(gsub(",","", as.character(y)))) | |
| drupal_plyrs_last30days[is.na(drupal_plyrs_last30days)] <- 0 | |
| ############################### | |
| corrgram(drupal_plyrs_last30days %>% | |
| dplyr::select(-Display.Name) %>% | |
| dplyr::select(1:8), order=TRUE, lower.panel=panel.shade, upper.panel=panel.pie, text.panel=panel.txt, | |
| main="Correlations between Behaviors in last 30 days") | |
| ################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment