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.
View oecd_membership_dummy.R
# ---------------------------------------------------------------------------- #
# Convert an HTML table of OECD member start dates to year-membership dummies
# Christopher Gandrud
# MIT License
# ---------------------------------------------------------------------------- #
# Load required packages
library(rio)
library(rvest)
library(countrycode)
View spell_features.R
#' Find key features of a spell including and ordered spell ID and each spell's
#' duration
#'
#' @param x a time ordered vector with values identifying a spell. It is
#' assumed that when a value in this vector changes that the spell has ended.
#' @param id logical specifying whether or not to return the spell ID
#' @param duration logical specifying whether or not to return the spell
#' duration.
#'
#' @examples