Code Monkey home page Code Monkey logo

Comments (8)

krlmlr avatar krlmlr commented on May 18, 2024

Thanks. Could you please point me to your project, or attach an archive?

from here.

pat-s avatar pat-s commented on May 18, 2024

In this example "Run All" chunks works. Knitting does not.

When changing here("spring-school-hsdar/data") to here("data"), i.e. making path relatives to the .Rmd file, knitting works but "Run All" does not work anymore (because paths to .Rproj files are wrong).

I also played around with knitr::opts_knit$set(root.dir = here()) but did not succeed. Even setting knitr::opts_knit$set(root.dir = "/Users/pjs/Desktop/test") (i.e. to the fixed path of the .Rproj dir) does not work.

You will need devtools::install_github("humburg/reportmd") for the example.

(Maybe its also a simple knitr problem and does not apply to here)

Archive.zip

from here.

krlmlr avatar krlmlr commented on May 18, 2024

Thanks. I'm seeing correct behavior with a simple document that is rendered with rmarkdown::html_document, but I can't get your example to run. I've installed the reportMD package, but knitting complains that a package "prompt" is missing, which I can't find.

Here's the minimal file I'm using in my tests:

---
title: "Part 1: Data investigation & preprocessing"
author: "Patrick Schratz"
date: "`r format(Sys.time(), '%a %d %b %Y')`"
output:
  reportMD::multi_document:
    toc: true
    fig_caption: true
    highlight: dracula 
    css: R.css
    use_namespace: false
params:
  version: !r 
---

```{r loadPackages, include=FALSE, cache=FALSE}
## load additional packages in this chunk
library(here)
```

```{r}
here()
```

Can you confirm that it works correctly with the following file:

---
title: "Part 1: Data investigation & preprocessing"
author: "Patrick Schratz"
date: "`r format(Sys.time(), '%a %d %b %Y')`"
output:
  rmarkdown::html_document
params:
  version: !r 
---

```{r loadPackages, include=FALSE, cache=FALSE}
## load additional packages in this chunk
library(here)
```

```{r}
here()
```

from here.

pat-s avatar pat-s commented on May 18, 2024

Thanks for looking into it.
It should work if you delete 01_preprocessing_cache- there are some leftovers from my run in it. prompt can be found on Github.

I get the following error with here("spring-school-hsdar/data") using html_document:

Quitting from lines 76-78 (01_preprocessing.Rmd)
Error in if (x == "" | x == ".") { :
missing value where TRUE/FALSE needed
Calls: ... -> -> .rasterObjectFromFile

Using here("data") works. So same problem with html_document as with reportmd->

  • root dir of here() when knitting = .Rmd dir
  • root dir of here() when running chunks = .Rproj dir

Setting knitr::opts_knit$set(root.dir = foo) does not work.

from here.

krlmlr avatar krlmlr commented on May 18, 2024

Does my example file work for you? After deleting the cache I can run the first example, it works as expected both for "Run all" and "knit".

from here.

pat-s avatar pat-s commented on May 18, 2024

It works and it also works using reportMD::multi_document. I refer to the example I sent you.

However, I'm kind of lost right now. What does not work is the original source from which the example, which I sent to you, was extracted. It has the same files, the same code and the same directory structure.

Knitting there, I get

Quitting from lines 75-77 (01_preprocessing.Rmd)
Error in if (x == "" | x == ".") { :
missing value where TRUE/FALSE needed
Calls: ... -> -> .rasterObjectFromFile
In addition: Warning messages:
1: code chunks must not depend on the uncached chunk "listfiles"
2: code chunks must not depend on the uncached chunk "makeraster"
Execution halted

for both reportMD::multi_document or html_document. It again refers to

# list files
file <- here("spring-school-hsdar/data") %>% list.files(pattern = ".tif$", full.names = TRUE)

and knitting only works when using here("data").

You proofed that it works correctly and I can reproduce it on my local copy. So I assume that there is some nasty stuff going on in my source...(which I do not want you to bother with).

Thanks for your time checking the files etc! Much appreciated! I'll let you know if I'll ever find out what's going on here.

from here.

krlmlr avatar krlmlr commented on May 18, 2024

I'm getting consistent results with the following example, too:

---
title: "Part 1: Data investigation & preprocessing"
author: "Patrick Schratz"
date: "`r format(Sys.time(), '%a %d %b %Y')`"
output:
  reportMD::multi_document:
    toc: true
    fig_caption: true
    highlight: dracula 
    css: R.css
    use_namespace: false
params:
  version: !r 
---

```{r loadPackages, include=FALSE, cache=FALSE}
## load additional packages in this chunk
library(here)
library(magrittr)
```

```{r listfiles}
# list files
file <- here("spring-school-hsdar/data") %>% list.files(pattern = ".tif$", full.names = TRUE)
```

Next, we will read in these files as 'raster bricks' into R. 

```{r makeraster, dependson='listfiles'}
raster <- raster::brick(file[1])
raster
```

I'd suggest you try to remove code from your document step by step until the problem disappears. And I'd definitely be interested in the cause of this weird problem!

from here.

github-actions avatar github-actions commented on May 18, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

from here.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.