count r

  1. Open RStudio on your computer.
  2. Load the text file or data frame that you want to analyze using the read.table() or read.csv() function.
  3. Use the tolower() function to convert all the text to lowercase to ensure consistent counting of 'r' and 'R'.
  4. Use the str_count() function from the stringr package to count the occurrences of 'r' in the text. Use the argument ignore_case = TRUE to count both 'r' and 'R' together.
  5. Print or store the result to see the count of 'r' in the text data.