Skip to content

Instantly share code, notes, and snippets.

@scoavoux
scoavoux / gist:ccb2f4333626949838a0ff807da238ff
Created March 6, 2017 09:16
Compute odds.ratio and p.value for logit model report in stargazer
sg_or <- function(mod){
OR <- lapply(mod, function(x) as.data.frame(questionr::odds.ratio(x)))
re <- list(
or = lapply(OR, `[[`, "OR"),
ci = lapply(OR, `[`, 2:3),
p = lapply(OR, `[[`, "p")
)
return(re)
}
@scoavoux
scoavoux / raw_latex_comments.py
Created February 16, 2016 22:33
pandoc filter to pass raw latex comments, to bypass the %-escaping
#!/usr/bin/env python
# proposed this as an answer here: http://stackoverflow.com/a/35444147/4132844
from pandocfilters import toJSONFilter, RawInline
def comments(k, v, f, meta):
if k == 'Str' and v in ['%TC:ignore','%TC:endignore']:
return RawInline('latex', v)
if __name__ == "__main__":
toJSONFilter(comments)
@scoavoux
scoavoux / header_increase
Last active February 16, 2016 22:35
Increases markdown headers of one level
from pandocfilters import toJSONFilter, Header
# proposed as an answer here http://stackoverflow.com/a/35341506/4132844
def header_increase(key, value, format, meta):
if key == 'Header' and value[0] < 7:
value[0] = value[0] + 1
return Header(value[0], value[1], value[2])
if __name__ == "__main__":