Question: Please write your code in R and submit your script and results for each of the following. Suppose you are given the following plain text:
Please write your code in R and submit your script and results for each of the following.
Suppose you are given the following plain text: Members of the Senate and of the House of Representatives of the United States, I feel greatly honored that you should have thus invited me to enter the United States Senate Chamber and address the representatives of both branches of Congress. The fact that my American forebears have for so many generations played their part in the life of the United States, and that here I am, an Englishman, welcomed in your midst, makes this experience one of the most moving and thrilling in my life, which is already long and has not been entirely uneventful. I wish indeed that my mother, whose memory I cherish, across the vale of years, could have been here to see. By the way, I cannot help reflecting that if my father had been American and my mother British instead of the other way around, I might have got here on my own. In that case this would not have been the first time you would have heard my voice. In that case I should not have needed any invitation. But if I had it is hardly likely that it would have been unanimous. So perhaps things are better as they are. (6 points each)
Store the text into a character variable ptext
Spilt the text into individual characters. [Hint: use strsplit()]
Store all characters in ptext into a character vector. [Hint: use unlist()]
Change all text to upper case. [Hint: Use toupper]
Remove all non-alphabetic characters. [Hint: use gsub()]
Tabulate the frequencies of all characters. [Hint: use table()]
Assign the following to a variable named key: ZGYHXIWJVKULTMSARBQCPDOENF. These correspond to the characters in the alphabet such that Z substitutes A, etc. Repeat steps (b) and (c) for the variable named key.
Assign all uppercase letters of the alphabet to a variable called alpha. Repeat steps (b) and (c) for the variable named alpha.
Find the number of characters in ptext. [Hint: use nchar()]
Using the variables alphai and key, encrypt ptext into a variable named ctext.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
