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
seq(from = as.Date("2012/1/1"), to = as.Date("2019/1/1"), by = "month") |
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
dbListConnections( dbDriver( drv = "MySQL")) | |
lapply( dbListConnections( dbDriver( drv = "MySQL")), dbDisconnect) |
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
https://stackoverflow.com/questions/50661862/how-to-use-custom-sql-function-in-dbplyr | |
You can build your own SQL functions in R. They just have to produce a string that is a valid SQL query. I don't know the Jaro-Winkler distance, but I can provide an example for you to build from: | |
union_all = function(table_a,table_b, list_of_columns){ | |
# extract database connection | |
connection = table_a$src$con | |
sql_query = build_sql(con = connection, |
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
colnames(df)[1] <- "New name" |
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
library("reshape2") | |
my.df <- data.frame(ID=rep(c("A","B","C"), 5), TIME=rep(1:5, each=3), X=1:15, Y=16:30) | |
dcast(melt(my.df, id.vars=c("ID", "TIME")), ID~variable+TIME) |
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
library(dplyr) | |
library(tidyr) | |
df <- data.frame(A=c(1,1),B=c(NA,2),C=c(3,NA),D=c(NA,2),E=c(5,NA)) | |
df2 <- df %>% | |
group_by(A) %>% | |
fill(everything(), .direction = "down") %>% | |
fill(everything(), .direction = "up") %>% | |
slice(1) |
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
library(webshot) | |
file_name <- normalizePath("C://Users//username//Documents//prez.html") | |
webshot(file_name, "prez.pdf") |
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
name_name_name_id_seq | |
AS integer | |
START WITH 1 | |
INCREMENT BY 1 | |
_lastword\s*AS integer\s*START WITH | |
AS integer(?=\sSTART WITH) | |
# to replace |
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
readr::parse_number("ads052788R") |
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
df2 <- read.table(text = "", col.names = df1$name) |