Skip to content

Instantly share code, notes, and snippets.

View SachaEpskamp's full-sized avatar

Sacha Epskamp SachaEpskamp

View GitHub Profile
@SachaEpskamp
SachaEpskamp / gist:4954285
Created February 14, 2013 17:03
Slide 3 does not produce a plot. If I comment slide 1 out, it does!
\documentclass{beamer}
\begin{document}
<<echo=FALSE>>=
library("qgraph")
@
%%% SLIDE 1 %%%
\begin{frame}[fragile]{Weights matrices}
\begin{columns}
@SachaEpskamp
SachaEpskamp / server.R
Last active June 27, 2016 20:40
Statcheck web interface test
library('shiny')
library('statcheck')
shinyServer(function(input, output) {
Dir <- tempdir()
Results <- reactive({
# Copy to the directory:
@SachaEpskamp
SachaEpskamp / server.R
Created May 1, 2013 21:56
qgraph shiny test
library("shiny")
library("foreign")
library('qgraph')
shinyServer(function(input, output) {
#
# # Data import:
# output$data <- reactiveTable(function() {
# if (is.null(input$files)) {
# # User has not uploaded a file yet
@SachaEpskamp
SachaEpskamp / global.R
Last active December 17, 2015 09:59
Confirmatory LVCA interface. Requires multivar package which is in development.
library("qgraph")
library('multivar')
library('lavaan')
library("shinyIncubator")
library("shiny")
library("foreign")
BFreport <- function(x)
{
if (x > 10000)
@SachaEpskamp
SachaEpskamp / global.R
Last active December 17, 2015 12:09
semPlot UI for Lavaan models
library("semPlot")
library("lavaan")
@SachaEpskamp
SachaEpskamp / global.R
Last active December 17, 2015 21:49
Ising example
library("qgraph")
library("igraph")
library("Rcpp")
library("shiny")
download.file("http://sachaem47.fortyseven.versio.nl/files/IsingCppBinary.cpp", file <- tempfile(fileext=".cpp"))
sourceCpp(file)
@SachaEpskamp
SachaEpskamp / global.r
Created June 16, 2013 10:02
Example of matrixInput not working in Shiny 0.6 but working in 0.5.
library("shinyIncubator")
library("shiny")
@SachaEpskamp
SachaEpskamp / global.R
Last active October 22, 2021 08:55
A general shiny app to import and export data to R. Note that this can be used as a starting point for any app that requires data to be loaded into Shiny.
library("shiny")
library("foreign")
@SachaEpskamp
SachaEpskamp / getOSFfile.R
Last active October 2, 2016 06:56
getOSFfile
# Function to download OSF file:
getOSFfile <- function(
code, #Either "https://osf.io/XXXXX/" or just the code
dir = getwd(), # Output location
method = c("downloader","httr","curl") # First one is chosen
){
# Check if input is code:
if (!grepl("osf\\.io",code)){
URL <- sprintf("https://osf.io/%s/",code)
} else URL <- code
# Bayesian Exploratory/Confirmatory CFA:
# Functions:
# becfa: Runs the Bayesian Exploratory/Confirmatory factor analysis model. And compares it vs regular CFA plus frequentist CFAs
# becfa_mi: Runs the measurement invariance steps using ONLY BECFA
becfa_mi <- function(
model, # Lavaan model
data,