library(tidyverse)
mock_data <- tribble(
~park_name, ~count_2015,
"DISNEY_ANIMAL_KINGDOM", 10262808.79,
"DISNEY_CALIFORNIA_ADVENTURE", 7859777.858,
"DISNEY_HOLLYWOOD_STUDIOS", 10161975.17,
"DISNEYLAND", 15850608.32,
"DISNEYLAND_PARIS", 11303153.4,
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
project | |
|- DESCRIPTION # project metadata and dependencies | |
|- README.md # top-level description of content and guide to users | |
|- NAMESPACE # exports R functions in the package for repeated use | |
|- LICENSE # specify the conditions of use and reuse of the code, data & text | |
|- data/ # raw data, not changed once created | |
| +- my_data.csv # data files in open formats such as TXT, CSV, TSV, etc. | |
| | |
|- analysis/ # Series of folders for each step of the analysis |
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
# install.packages("VineCopula") | |
# install.packages("copula") | |
# install.packages("tigerstats") | |
library(VineCopula) | |
library(copula) | |
library(tigerstats) | |
set.seed(123) | |
N=200 | |
dim=dim |
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
ip <- as.data.frame(installed.packages()[,c(1,3:4)]) | |
rownames(ip) <- NULL | |
ip <- ip[is.na(ip$Priority),1:2,drop=FALSE] | |
write.csv(ip, "package_list.csv") | |
print(ip, row.names=FALSE) |
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
# taken from https://www.r-bloggers.com/list-of-user-installed-r-packages-and-their-versions/ | |
ip <- as.data.frame(installed.packages()[,c(1,3:4)]) | |
rownames(ip) <- NULL | |
ip <- ip[is.na(ip$Priority),1:2,drop=FALSE] | |
write.csv(ip, "r_package_list.csv") | |
print(ip, row.names=FALSE) | |
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
f2 <- function(a, b, ...) { | |
a * 10 | |
} | |
f2(10, stop("This is an error!")) | |
objs <- mget(ls("package:base"), inherits = TRUE) | |
funs <- Filter(is.function, objs) | |
is_not_primitive <- function(x){ |
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
# find the names in one but not the other | |
# names(dat_dist)[((names(dat_dist) %in% names(dat_dist_aed)) == FALSE)] |
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
# this is taken from Amy Whitehead's great blog: https://amywhiteheadresearch.wordpress.com/2016/12/01/santas-little-helper/ | |
SantasLittleHelper <- function(myFrame,guestList,conflictCols = NULL){ | |
myTest <- TRUE | |
nElves <- 0 | |
while (myTest == TRUE){ | |
myOut <- data.frame(gifter = myFrame[,guestList], | |
giftee = sample(myFrame[,guestList], | |
replace = FALSE, |
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
``` r | |
# running | |
## Requires package 'openNLPmodels.en' from the repository at | |
## <http://datacube.wu.ac.at>. | |
# install.packages("openNLPmodels.en", | |
# repos = "http://datacube.wu.ac.at/", | |
# type = "source") |
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
matrix_to_df_firstline_header <- function(mat){ | |
requireNamespace("purrr") | |
mat %>% | |
## cut columns into lists | |
apply(2, function(s) list(s)) %>% | |
flatten %>% | |
map(flatten_chr) %>% | |
## set names to the first element of the list | |
{set_names(x = map(., ~ .x[-1]), |