12  Conclusion

12.1 What we have not covered

  • shell scripting
  • editing files
  • file permissions
  • user information
  • pipes
  • awk
  • sed

12.2 Summary

  • Shell is a text based application for viewing, handling and manipulating files
  • It is also known by the following names
    • CLI (Command Line Inteface)
    • Terminal
    • Bash (Bourne Again Shell)
  • Use system2() and processx::run() in R to execute shell commands
  • Use Rscript -e or R -e to execute R scripts from the command line
  • RStudio includes a Terminal (from version 1.1.383)
  • Execute commands from shell script in RStudio using Ctrl + Enter
  • RMarkdown supports bash, sh and awk

12.3 References

  • https://tldr.sh/
  • https://blog.rstudio.com/2017/08/11/rstudio-v1-1-preview-terminal/
  • https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal
  • https://bookdown.org/yihui/rmarkdown/language-engines.html#shell-scripts
  • https://github.com/kirillseva/tldrrr
  • https://fs.r-lib.org/articles/function-comparisons.html
  • https://livefreeordichotomize.com/2017/09/28/r-release-names/
  • https://stackoverflow.com/questions/13478375/is-there-any-authoritative-documentation-on-r-release-nicknames
  • http://www2.imm.dtu.dk/courses/02333/cygwin_tutorial/index.html
  • https://tutorial.djangogirls.org/en/intro_to_command_line/
  • https://ss64.com/
  • https://www.learnenough.com/command-line-tutorial

12.3.1 Feedback

If you see mistakes or want to suggest changes, please create an issue on the source repository or reach out to us at support@rsquaredacademy.com.

12.4 Exercises

  1. Navigation + R mapping: from the shell, navigate into cline/ and run ls. Then do the same from R with system2(command = "ls") and by running R from the shell with Rscript -e "dir()". Confirm all three approaches list the same files.
  2. Search + R mapping: from the shell, search package_names.txt for a pattern with grep -i. Then repeat the search from R by wrapping the same command in system2(..., stdout = TRUE). Confirm both return the same matches.
  3. End-to-end mini-workflow: navigate to a folder, locate a .R script by searching, and execute it from the shell with Rscript. List the three steps you took and the final evidence (script output or created file) proving the workflow succeeded.

Worked solutions in solutions/conclusion.md (attempt first).