Comments (8)
Thanks. Could you please point me to your project, or attach an archive?
from here.
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
)
from here.
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.
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.
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.
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.
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.
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)
- here often fails to identify directory on google drive on windows HOT 3
- Move `master` branch to `main` HOT 3
- `here::u_r()`
- Failing to install here library with R 4.1.2
- Quarto.qmd does not render with library(here) HOT 5
- Can here() give the short path in windows, to make compatible with use cases where a path with spaces will fail? HOT 3
- Here not set correctly on Mac HOT 2
- Help: use Here with write.csv HOT 3
- Non-R-dominant folder setup HOT 9
- [feature request] detect and respect names HOT 1
- [help] how can I use here() in different R sessions HOT 1
- Not recognizing the .here file in root directory HOT 4
- Suggestion: `list.files()` with and for here HOT 1
- here() package conflicts in recent R/RStudio HOT 1
- There is no reponse when library (here) in vsocde radian console HOT 1
- here incorrect working directory using cronr package HOT 1
- Broken link in README.md
- Empty string breaks paths
- Feature idea - here::right_here()
- does not seem to be case sensative HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from here.