tips and tricks

Han Oostdijk


Date last run: 28Feb2020


Task Command Remark
Search in files grep -ri ‘text’ recursive and case insensitive
Search in files grep -n ‘text’ show line numbers
Search in R files grep -ri ‘trace’ --include *.R
Helpinfo for grep grep --help NB repeated - !
Find filename(s) find . -name ‘*mag2*‘ find files below current folder containing ‘mag2’ (in Terminal)

R Debugging



browser() commands

From browser() function help info:

Command Description
c exit the browser and continue execution at the next statement
cont synonym for c
f finish execution of the current loop or function
help print this list of commands
n evaluate the next statement, stepping over function calls. For byte compiled functions interrupted by browser calls, n is equivalent to c
s evaluate the next statement, stepping into function calls. Again, byte compiled functions make s equivalent to c
where print a stack trace of all active function calls
r invoke a “resume” restart if one is available; interpreted as an R expression otherwise. Typically “resume” restarts are established for continuing from user interrupts
Q exit the browser and the current evaluation and return to the top-level prompt

Two methods to include code with highlighting. See that the two paths are different. In the first case the base directory is the note or post directory and in the second case the base directory is the project library.

`​``{r echo=T,eval=T,comment=''}

```{r include2,code=readLines("./R/update_HOQC.R",warn=F),eval=F}

test only one file in active package

testthat:::test_package_dir(package = 'tabr', 
   test_path = './tests/testthat',
   filter = 'phrase',

include code chunks in text

In the section above we showed three consecutive backticks . This is not so easy as it seems because we generated the section (in fact the whole entry) with knitr where three such backticks are ‘eaten’ after being considered to be code block delimeters. See explanation. The second block used method 1 (adding empty string) in the explanation and for the first block the second (zero-width space) method was used.

include paired asteriks (*) in text

Paired asteriks are used to italicise a phrase. When you just want to display a phrase within asteriks e.g. *italics* use the html escape code *  .

include non-breaking space in text

Use the html-code    .

include session_info chunk


`​``{r child='../../local_files/session_info.Rmd'} 

to include the standard session_info chunk.

solution for empty line before last entry in list

After hugo version 0.57 I noticed that a list immediately followed by a code block forces an empty line between the list and its last entry. This can be solved by inserting a new line and a comment like <!-- inserted to avoid incorrect list ending -->
after the last entry.

documentation with Roxygen2

Since version 2.7 there are several website with improved information about Roxygen2:

activate Git in RStudio

When an RStudio project is created without Git, there is no invisible indication of Git functionality. Select/open the terminal pane and make sure that the active folder is the main folder of the project. Then type git init in the terminal pane. After closing and reopening the project in RStudio the Git pane will show.

keyboard shortcuts

From Handboek Internetresearch & datajournalistiek and 47 Keyboard Shortcuts That Work in All Web Browsers

Ctrl+L: goto address field
Ctrl+mouse click: open the link you clicked on in an new tab
Ctrl+W: close the current tab
Ctrl+T: open a new tab
Ctrl+N: open a new window
Ctrl+Shift+N: open a new anonymous window
Ctrl+(+Shift)Tab: switch between tabs
Ctrl+R: refresh page
function F11: toggle fullscreen mode
Alt+(left/right)arrow: previous/next page
keep previous button pressed: history

Google (Groups) Common search techniques

From Common search techniques and Handboek Internetresearch & datajournalistiek :

Search social media: Put @ in front of a word to search social media. For example: @twitter
Search for a price: Put $ in front of a number. For example: camera $400
Search hashtags: Put # in front of a word. For example: #throwbackthursday
Exclude words from your search: Put - in front of a word you want to leave out. For example, jaguar speed -car
Search for an exact match: Put a word or phrase inside quotes. For example, “tallest building”
Search within a range of numbers: Put .. between two numbers. For example, camera $50..$100
Combine searches: Put “OR” between each search query. For example, marathon OR race
Search for a specific site: Put “site:” in front of a site or domain. For example, or
Search for related sites: Put “related:” in front of a web address you already know. For example,
See Google’s cached version of a site: Put “cache:” in front of the site address
Restrict name to author (in Google Groups): Put “authorname:” in front of the name
Restrict searches: Put AND (or nothing) between each search query
Search nearby words : Put “NEAR” between two search wordse
Wildcard: Put * in search string or word