Read contents of system command to dataframe in R
<p>I would like to list all files in a directory (including sub-directories), then read this into a dataframe in R.</p>

<p>Currently I have attempted this with system commands. I have managed to list all files with a command like the one below:</p>

<p><code>system("ls -l $(find ~/starting_location/ -type f)")</code></p>

<p>But I can't figure out how to then get this into a dataframe in R. I have been trying at least to write this to a text file, then import it, but this hasn't worked either (example below).</p>

<p><code>system("ls -l $(find ~/starting_location.prague.UDM/ -type f) &gt; ~/starting_location/file_list.txt")</code></p>

<p>The above command is erroring with: </p>

<p><code>ls: cannot access starts: No such file or directory
ls: cannot access here: No such file or directory</code></p>

<p>Would someone be able to suggest what is wrong with my code line / is there a way to get this directly to R without having to write it to a text file?</p>