Skip to content

Instantly share code, notes, and snippets.

@eaurele
eaurele / r.snippets
Last active April 4, 2019 15:03
My RStudio snippets `~/.R/snippets/r.snippets`
snippet view
View(.Last.value)
snippet snap_df
if (!is.data.frame(.Last.value)) {
warning("Last value is not a data.frame")
} else {
assign(".Last.df", .Last.value, pos = .GlobalEnv)
message("Assigned last created data.frame to `.Last.df`")
invisible()
@eaurele
eaurele / load_excel_files.R
Last active August 1, 2016 16:48
Load a bunch of Excel files at once in R
library(magrittr)
library(readxl)
folder <- "./Folder full of folders full of xls or xlsx files/"
# Store all data in one list of lists (ie one list of workbooks, each
# workbook is a list of sheets, each sheet is a dataframe (or an error message if applicable))
data_ <-
# List all xls(x) files in folder (recursively)
list.files(path = folder, pattern = "xlsx?$", full.names = TRUE,
recursive = TRUE, ignore.case = TRUE) %>%