I am trying to loop trough a directory its sub directories to print all images.
My setup is RStudio 1.4 on Ubuntu 20.10.
This is my RMarkup R chunk:
```{r, echo=FALSE}
path = "/home/bruker/Pictures"
out.file<-""
file.names <- dir(path)
for(i in 1:length(file.names)){
file <- read.table(file.names[i],header=TRUE, sep=";", stringsAsFactors=FALSE)
}
```
It gives the following error:
Error in file(file, "rt") : cannot open the connection Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> read.table -> file Exectuion halted
The directory exists. I get this in the terminal:
bruker@ubuntu:~$ tree /home/bruker/Pictures
locales-launch: Data of en_US locale not found, generating, please wait...
/home/bruker/Pictures
├── dog.jpeg
└── samsung.png
0 directories, 2 files
Also this code prints the files, so it the "file" variable assignemtns that doesnt work:
```{r, echo=FALSE}
path = "/home/bruker/Pictures"
out.file<-""
file.names <- dir(path)
dir(path)
```
Output:
## [1] "dog.jpeg" "samsung.png"