I'm trying to delete a folder path defined as a R variable filepath
by using a bash
code chunk in my Rmarkdown.
Following up from a previous question as well as from Yihui's example , I passed my variable filepath
into the bash
chunk with the following R code chunk:
```{r}
Sys.setenv(FILEPATH = filepath)
```
While I'm able to echo
my variable in the bash
chunk, there was an error when I tried rm -r
my $FILEPATH
variable.
```{bash}
echo $FILEPATH
rm -r $FILEPATH
```
~/Projects/test_threshold
rm: ~/Projects/test_threshold: No such file or directory
I've tried assigning my variable directly in the bash terminal for deletion and it worked.
deletedir=~/Projects/test_threshold
rm -r $deletedir
Any suggestions on what I've done wrong? Thanks for your help!