library(tidyverse)
# Make yard size, the presence/absence of a home garden, and attitudes toward the
# environment all correlated with each other. Home garden will be binary, so I split
# it based on some threshold later. Attitudes toward the environment will be on a
# scale of 1-10, so I rescale and ceiling it later
mu <- c(yard_size = 20000, home_garden = 30, attitude_env = 70)
stddev <- c(yard_size = 10000, home_garden = 15, attitude_env = 40)
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
library("shiny") | |
library("foreign") |
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
# Shamlessly stolen from: | |
# https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/ | |
# create a list of all installed packages | |
ip <- as.data.frame(installed.packages()) | |
head(ip) | |
# if you use MRO, make sure that no packages in this library will be removed | |
ip <- subset(ip, !grepl("MRO", ip$LibPath)) | |
# we don't want to remove base or recommended packages either\ | |
ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),] |
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
# theme options based on hour of day ------------------------------------------- | |
# based on https://github.com/rstudio/rstudio/issues/1579 | |
setHook("rstudio.sessionInit", function(chooseTheme) { | |
if (chooseTheme) { | |
if (format(as.POSIXct(Sys.time(), format = "%H:%M:%S"), "%H") %in% c(0:6, 20:23)) { | |
if (rstudioapi::getThemeInfo()$editor != "Solarized Dark") rstudioapi::applyTheme("Solarized Dark") | |
} else { | |
if (rstudioapi::getThemeInfo()$editor != "Solarized Light") rstudioapi::applyTheme("Solarized Light") | |
} | |
} |
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
## load rtweet | |
library(rtweet) | |
## store bounding box coordinates for state of nevada | |
nv <- c(-120.00647, 35.00186, -114.03965, 42.00221) | |
## initialize output vector and Midwestern 'ope' counter | |
s <- list() | |
ope <- 0L |
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
# What's the most natural way to express this code in base R? | |
library(dplyr, warn.conflicts = FALSE) | |
mtcars %>% | |
group_by(cyl) %>% | |
summarise(mean = mean(disp), n = n()) | |
#> # A tibble: 3 x 3 | |
#> cyl mean n | |
#> <dbl> <dbl> <int> | |
#> 1 4 105. 11 | |
#> 2 6 183. 7 |
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
# The difference between the `sep` and `collapse` arguments | |
# in paste can be thought of like this: | |
# | |
# paste can accept multiple *vectors* as input, and will | |
# concatenate the ith entries of each vector pairwise | |
# (or tuplewise), if it can. | |
# | |
# When you pass paste multiple vectors, sep defines what | |
# separates the entries in those tuple-wise concatenations. | |
# |
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
<?php | |
/** | |
* This recipe adds billing fields to the Membership Profile page. | |
* | |
* It is intended for use with the Register Helper Add On: | |
* https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. |
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
<?php | |
/* | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* This will add billing fields to Add Member and the user's profile page. | |
*/ | |
function add_billing_fields_to_add_member_profile() { | |
//check for register helper | |
if(!function_exists("pmprorh_add_registration_field")) | |
return; |