I'd like to pull child documents from github to knit as child items inside an rmarkdown document.
Using yihui's example from allowing child markdown files we can have a main doc (modified) that refers to the child doc on github instead of downloading it first.
I've resolved a Windows compatibility issue, and am now getting a setwd()
fail.
How do you correctly setup a knitr document to knit child items from a URL? (if possible)
Initial (on windows)
You can also use the `child` option to include child documents in markdown.
```{r test-main, child='https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd'}
```
You can continue your main document below, of course.
```{r test-another}
pmax(1:10, 5)
```
Error output
## Quitting from lines 4-4 (https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd)
## Error in readLines(if (is.character(input2)) { :
## cannot open the connection
## Calls: <Anonymous> ... process_group.block -> call_block -> lapply -> FUN -> knit -> readLines
## In addition: Warning message:
## In readLines(if (is.character(input2)) { : unsupported URL scheme
## Execution halted
This was erroring because the readLines command was unable to access HTTPS by default when working on Windows.
v2 (on windows)
To correct for the readLines issue I added a chunk that adds the ability to access HTTPS
You can also use the `child` option to include child documents in markdown.
```{r setup, results='hide'}
setInternet2(use = TRUE)
```
```{r test-main, child='https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd'}
```
You can continue your main document below, of course.
```{r test-another}
pmax(1:10, 5)
```
Error output
## processing file: https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd
## Quitting from lines 2-2 (https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd)
## Quitting from lines NA-7 (https://raw.githubusercontent.com/yihui/knitr/master/inst/examples/child/knitr-child.Rmd)
## Error in setwd(dir) : cannot change working directory
## Calls: <Anonymous> ... process_group.inline -> call_inline -> in_dir -> setwd
## Execution halted
Trying to add in a setwd("~")
into chunk setup
has no impact on the error message