View beta_plot_basic.R
#' @import ggplot2
#' @export
beta_plot <- function(n = 10000, a = 1, b = 3) {
# draw distributions
sims <- rbeta(n = n, shape1 = a, shape2 = b)
# convert to data frame for ggplot2 compatability
sims <- data.frame(x = sims)
View zeligverse_worflow_5.1.1.9000.R
---
title: "The zeligverse and beyond"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
[for Zelig version 5.1.1.9000, [setdirect branch](https://github.com/IQSS/Zelig/tree/setxdirect)]
View rrst_to_rmd.R
#' Converts an R reStructuredText document (Rrst) to R Markdown (Rmd)
#'
#' @param input character string with the path of the file to convert
#' @param output optional character string with the path for the output file
#' @param out_dir optional character string with the output directory. Not used
#' if \code{output} is supplied.
#' @param output_file logical whether to return the output to a file or not.
#' If \code{FALSE}, then \code{output} and \code{out_dir} are ignored.
#'
#' @importFrom readr read_file write_file
View parse.formula.R
parse.formula<-function( formula, model,data=NULL){
if(class(formula)[[1]]=="multiple")
return(formula)
nrUserOpt<-nrUserReq<-nrUserFixed<-nrUserSubreq<-0
userOpt<-userReq<-userFixed<-userSubreq<-list()
fc <- paste("describe.", model, sep = "")
if (!exists(fc))
stop("describe.",model," does not exsist")
modelReq<-do.call(fc,list())
View set_skip_ex.R
# Initialize Zelig5 least squares object
z5 <- zls$new()
# Estimate ls model
z5$zelig(Fertility ~ Education, data = swiss)
# Simulate quantities of interest
z5$sim()
# Plot quantities of interest
View z4_simple_ex.R
# Estimate ls model
z4 <- zelig(Fertility ~ Education, data = swiss, model = 'ls')
# Set Eductation to 5 and 15
z4_set_low <- setx(z4, Education = 5)
z4_set_high <- setx(z4, Education = 15)
# Simulate results
z4_sim <- sim(z4, x = z4_set_low, x1 = z4_set_high)
View zls_simple_example.R
# Load the Zelig package
library(Zelig)
# Initialize Zelig5 least squares object
z5 <- zls$new()
# Estimate ls model
z5$zelig(Fertility ~ Education, data = swiss)
# Set Education to 5 and 15
View fail_knitr.R
knitr::opts_knit$set(stop_on_error = 2L)
View generate_password.R
#' Generate a random password with R
#'
#' @param n_char integer with the number of characters for the resulting
#' password.
#' @param n_special integer with the number of special (non-letter or number)
#' characters in the password.
#' @param special_chars character vector with the special characters that can be
#' included in the password.
#'
#' @examples
View monadic_spatial_weights.R
#' Find monadic spatial weights for continuous numeric data in a time series data set
#' df a data frame containing the unit ID variable and time variables as well as
#' 'location' and dependent variables.
#' id_var a character string identifying the unit ID variable in \code{df}.
#' time_var a character string identifying the time variable in \code{df}.
#' location_var a character string identifying the location of the units in
#' \code{df}. This is used to create the weighting matrix. Note that the function
#' finds the relative distance between the units by subtracting their 'location'.
#' y_var a character string identifying the dependent variable in \code{df}. Note that
#' an independent variable could also be supplied.