reproducible-research

How should Jupyter extensions be installed and enabled for being reproducible?

谁说胖子不能爱 提交于 2019-12-10 15:42:45
问题 I'd like to make interactive slide set (for a presentation with some live coding in python) with RISE a.k.a. live_reveal, which is a notebook extension for Jupyter. I'd like the slide set to be usable by others (and by my future self) without too many manual steps (and without relying on hosted Jupyter solutions), thus I've chosen pipenv to manage dependencies. I can get started with pipenv install RISE pipenv run jupyter nbextension install rise --py --sys-prefix pipenv run jupyter

Why would an R package load random numbers?

扶醉桌前 提交于 2019-12-10 15:06:44
问题 Recently, I was reading the documentation for the caret package when I noticed this: Also, please note that some packages load random numbers when loaded (directly or via namespace) and this may effect [ sic ] reproducibility. What are possible use cases for packages loading random numbers? This seems to be counter to the idea of reproducible research and might interfere with my own attempts to set.seed . (I've started setting seeds closer to code that requires random number generation

Using apaTables or apaStyles packages with knitr

人走茶凉 提交于 2019-12-08 19:32:25
Problem Social scientists format tables and documents with APA style . There are packages like stargazer and xtable (here is an extensive list ) that provide clean table formatting for those using latex and knitr . However , these packages do not conform to APA style rules in all cases. Building and formatting tables from scratch is time consuming. Fortunately, there are two R packages for creating tables and documents compliant with APA style guidelines: apaStyle and apaTables . Unfortunately, both packages only output to MS Word. Questions Is there a way to use APAStyle and APATables so that

Using apaTables or apaStyles packages with knitr

若如初见. 提交于 2019-12-08 08:03:45
问题 Problem Social scientists format tables and documents with APA style. There are packages like stargazer and xtable (here is an extensive list) that provide clean table formatting for those using latex and knitr . However , these packages do not conform to APA style rules in all cases. Building and formatting tables from scratch is time consuming. Fortunately, there are two R packages for creating tables and documents compliant with APA style guidelines: apaStyle and apaTables . Unfortunately,

Loops in Rmarkdown: How to make an in-text figure reference? Figure captions?

老子叫甜甜 提交于 2019-12-07 12:32:07
问题 {r setup, include=FALSE, message=FALSE, results="hide"} knitr::opts_chunk$set(echo = TRUE) library(knitr) library(kfigr) library(dplyr) library(png) library(grid) library(pander) library(ggplot2) Question Loops in rmarkdown: in-text figure reference? figure captions? Goal Use a for loop to create sections with text, in-text results, and multiple figure references with associated figure captions in the figure list. The figure references/numbering should be seemless with figures numbered before

Use rmarkdown/knitr to hold all code until the end

℡╲_俬逩灬. 提交于 2019-12-07 00:13:58
问题 I'd like to be able to generate a document using knitr/rmarkdown that keeps all the output together, but leaves the code until the end, ideally as a referenced footnote of sorts (i.e. the code for each figure or output can be looked up in the appendix using a footnote). Is this possible? 回答1: If I understand correctly what you mean. You can add a label to your original code chunk and then refer to it using a ref.label property and prevent its further execution with eval=FALSE . For instance:

Loops in Rmarkdown: How to make an in-text figure reference? Figure captions?

老子叫甜甜 提交于 2019-12-05 21:34:33
{r setup, include=FALSE, message=FALSE, results="hide"} knitr::opts_chunk$set(echo = TRUE) library(knitr) library(kfigr) library(dplyr) library(png) library(grid) library(pander) library(ggplot2) Question Loops in rmarkdown: in-text figure reference? figure captions? Goal Use a for loop to create sections with text, in-text results, and multiple figure references with associated figure captions in the figure list. The figure references/numbering should be seemless with figures numbered before and after these new sections. Note: The figures referenced in the for loop are generated earlier in

Reproducible splitting of data into training and testing in R

本秂侑毒 提交于 2019-12-04 22:26:00
A common way for sampling/splitting data in R is using sample , e.g., on row numbers. For example: require(data.table) set.seed(1) population <- as.character(1e5:(1e6-1)) # some made up ID names N <- 1e4 # sample size sample1 <- data.table(id = sort(sample(population, N))) # randomly sample N ids test <- sample(N-1, N/2, replace = F) test1 <- sample1[test, .(id)] The problem is that this isn't very robust to changes in the data. For example if we drop just one observation: sample2 <- sample1[-sample(N, 1)] samples 1 and 2 are still all but identical: nrow(merge(sample1, sample2)) [1] 9999 Yet

knitr - error when importing python module

一个人想着一个人 提交于 2019-12-01 02:48:36
I am having trouble when running the python engine in knitr. I can import some modules but not others. For example I can import numpy but not pandas. {r, engine='python'} import pandas I get the error. Quitting from lines 50-51 (prepayment.Rmd) Error in (knit_engines$get(options$engine))(options) : Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pandas Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> <Anonymous> In addition: Warning message: running command ''python' -c 'import pandas' 2>&1' had status 1

Loops with captions with knitr

帅比萌擦擦* 提交于 2019-11-30 14:19:06
问题 I am wondering if there is an easy way to produce a bunch of tables or graphics with variable captions in knitr . The only way I know is this: (simplified from https://github.com/yihui/knitr-examples/blob/master/075-knit-expand.Rnw). But it is a drag to collect the output into src and then print it after the loop, because I want to write a function to produce such a loop from an arbitrary dataset. \documentclass{article} \title{Using knit\_expand() for templates} \author{Yihui Xie} \begin