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
| # List unique values in a DataFrame column | |
| # h/t @makmanalp for the updated syntax! | |
| df['Column Name'].unique() | |
| # Convert Series datatype to numeric (will error if column has non-numeric values) | |
| # h/t @makmanalp | |
| pd.to_numeric(df['Column Name']) | |
| # Convert Series datatype to numeric, changing non-numeric values to NaN | |
| # h/t @makmanalp for the updated syntax! |
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
| DATA %>% rename_(.dots=setNames(names(.), tolower(gsub("FROM", "TO", names(.))))) | |
| ## Taken from: http://stackoverflow.com/questions/30382908/r-dplyr-rename-variables-using-string-functions |
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
| # Notes: | |
| # 1. rename staff number field in each spreadsheet to "emp_id" | |
| # 2. When adding new spreadsheets, convert emp_id class to character to allow anti_join() to work | |
| # 3. if time allows, automate cleaning of column names and drop unused from hr-list.csv | |
| library(dplyr) | |
| library(readr) |
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
| ##Split text in the form "surname, firstname" and concantenate | |
| to (firstname lastname) | |
| ##Surname | |
| =LEFT(TEXT,(FIND(",",TEXT)-1)) | |
| ##First name | |
| =RIGHT(TEXT,LEN(I6) - E6 -1) | |
| ##Concantenate |
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
| # Read data and extract start / finish columns | |
| setwd("/Volumes/emr/Testing/") | |
| raw_file <- read.csv("theo_Epic GANTT 20150605.csv") | |
| raw_start <- raw_file[,"Start"] | |
| raw_finish <- raw_file[,"Finish"] | |
| # Parse date-time and revemove times | |
| raw_start2 <- dmy(raw_start) | |
| new_start <- paste(day(raw_start2), month(raw_start2), year(raw_start2),"/") |