In: Computer Science
R language
create file Ass2.txt
"("Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown" "John, Malkovich" "Sandy, Olsson" "Raymond, Babbitt" "Jack, Sparrow" "Melanie, Daniels" "Stanley, Kowalski" "Darth, Vader" "Jack, Torrance" "Aurora, Greenway" "Sam, Spade" "Hans, Beckert" "Max, Rockatansky" "Tony, Manero")".
a. Import the data into a vector named name and create an email address for each student as follows. The general format of an email address is username (at) domain. For each student, username is the name of the student in lowercase, with a period separating the first name and the last name if a last name is provided; and domain is IloveR.edu. Name the vector that contains the email addresses as email.
b. Export the data in email to a plain-text file named email.txt in the following format: • Use the column names as the header line.
• There should be no quotes or row names. • Use the comma as a separator.
Note (Output file will be automatically created)
I have created a link so that you can access the whole file,
Links for codes and Files (Note:- It will expire in 1 week) |
https://filebin.net/7c0tmtbs1e4guqm8 |
This link contains 3 files |
Ass2.txt, email.R and email.txt |
Output file (email.txt)
Code in R |
name <- scan("Ass2.txt",what = character()) # reading
file #Iterating over daataframe and creating email ids |
Ass.txt |
"Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown" "John, Malkovich" "Sandy, Olsson" "Raymond, Babbitt" "Jack, Sparrow" "Melanie, Daniels" "Stanley, Kowalski" "Darth, Vader" "Jack, Torrance" "Aurora, Greenway" "Sam, Spade" "Hans, Beckert" "Max, Rockatansky" "Tony, Manero" |