In this set of exercises we will practice functions that enable us to manipulate strings.You can find more about string manipulation functions in Handling and Processing Strings in R e-book.
Answers to the exercises are available here.
If you have different solution, feel free to post it.
Load text from the file and print it on screen. Text file contains excerpt from novel “Gambler” by Fyodor Dostoyevsky.
How many paragraphs is there in the excerpt?
How many characters is there in the excerpt
Collapse paragraphs into one and display it on the screen (un-list it).
Convert the text to uppercase and save it to new file “gambler-upper.txt”.
Change all letters ‘a’ and ‘t’ to ‘A’ and ‘T’.
Does the text contain word ‘lucky’?
How many words are there in the excerpt, assuming that words are sub-strings separated by space or new line character?
How many times is word money repeated in the excerpt?
Ask the user to input two numbers, divide them and display both numbers and the result on the screen, each of them formatted to 2 decimal places.