title: File Reading
output: html_document
params:
user1: "C:/Users/myDir/Desktop/apples.jpeg"
user2: "C:/Users/myDir/Desktop/oranges.jpeg"
Lets say I have the following file paths set in params in a Rmardown file. Now I set a separate chunk for each file as follows:
```{r}
image_read(params$user1)
```
```{r}
image_read(params$user2)
```
Now lets say I want to knit the document but the path I have specified for user2 is not available. So I updated my chunks and added the following so if path is not available or correct, the chunk is not evaluated.
```{r, eval = file.exists(params$user2)}
image_read(params$user2)
What I want to do is to somehow specify if file does not exist then upload another image from a default path that I have specified in a separate chunk at the top of my file
```{r}
default_image <- "C:/Users/myDir/Desktop/default.jpeg"
```
So essentially whenever a file path is missing, I want to replace it with this default image. Any help would be appreciated
Aucun commentaire:
Enregistrer un commentaire