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()andprocessx::run()in R to execute shell commands - Use
Rscript -eorR -eto 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,shandawk
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
- Navigation + R mapping: from the shell, navigate into
cline/and runls. Then do the same from R withsystem2(command = "ls")and by running R from the shell withRscript -e "dir()". Confirm all three approaches list the same files. - Search + R mapping: from the shell, search
package_names.txtfor a pattern withgrep -i. Then repeat the search from R by wrapping the same command insystem2(..., stdout = TRUE). Confirm both return the same matches. - End-to-end mini-workflow: navigate to a folder, locate a
.Rscript by searching, and execute it from the shell withRscript. 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).