Last active
August 29, 2015 14:05
-
-
Save maartenvanvliet/e29930145551f36d8758 to your computer and use it in GitHub Desktop.
R convenience helpers
This file contains 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
#First differences, NA for first value | |
diff_na <- function(vector){ | |
return c(NA, diff(value)) | |
} | |
#Renames column | |
col.mv <- function(dataframe, old_name, new_name){ | |
names(dataframe)[names(dataframe)==old_name] <- new_name | |
return dataframe | |
} | |
#convert numbers with commas to integers | |
comma_numbers_to_int <- function(col){ | |
strtoi(gsub(",", "", c)) | |
} | |
#delete column | |
col.rm <- function(df,col){ | |
df[, !(colnames(df) %in% c(col))] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment