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
| a <- jsonlite::fromJSON("raw_data/countries.json") | |
| DT <- data.table::rbindlist(a) |
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
| usethis::edit_r_profile() |
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(as.Date("2010-02-01"), length=24, by="1 month") - 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
| sudo su - -c "R -e \"install.packages('dplyr', repos='http://cran.rstudio.com/')\"" |
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
| dplyr does not include commands to insert or update records in a database, so there is not a complete native dplyr solution for this. But you could combine dplyr with regular SQL statements to avoid bringing the data to R. | |
| Let's start by reproducing your steps before the collect() statement | |
| library(dplyr) | |
| pg <- src_postgres() | |
| reg_data <- tbl(pg, "reg_data") |
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
| options(error = function() { | |
| subject.msg <- paste0("Error Subject, ", format(Sys.time(), "%A %d %B %Y %X")) | |
| from <- "sender@mail" | |
| body <- geterrmessage() | |
| mailControl = list(smtpServer = "mail.server.com", smtpPort = "25") | |
| sendmail(from = from, | |
| to = c("recipient@one.com","recipient@two.com"), | |
| subject = subject.msg, | |
| msg = body, |
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
| transform(df, index = as.Date(index, frac = 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
| bind_rows(list_of_dataframes, .id = "column_label") |
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
| myfunction<- function(values, index){ | |
| cat("Adding values (", index, "): ", values[1], "...", values[2], " = ", sum(values), "\n" ) | |
| invisible(values[1] + values[2]) | |
| } | |
| mylist <- list(c(5, 4), c(3, 2), c(1, 3)) | |
| mapply(myfunction, mylist, seq_along(mylist)) |
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
| grep("^name$", colnames(df)) |