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