Created
September 15, 2018 02:42
-
-
Save jcheong0428/e6b560ce625b7d36ff087c8b402da7ce to your computer and use it in GitHub Desktop.
Set of codes to setup rpy2 environment to python notebook
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
# First load rpy2 | |
%load_ext rpy2.ipython | |
# Then load packages in a separate cell | |
%%R | |
require('lme4') | |
require('lmerTest') | |
require('lattice') | |
require('boot') | |
require('sjPlot') | |
require('optimx') | |
options("scipen"=999, "digits"=5) | |
r2 <- function(m) { | |
lmfit <- lm(model.response(model.frame(m)) ~ fitted(m)) | |
# summary(lmfit)$r.squared | |
summary(lmfit)$adj.r.squared | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment