Question

In: Computer Science

R language create file Ass2.txt "("Macauley, Culkin" "Antoine, Doinel" "Ace, Ventura" "Tommy, DeVito" "Oda Mae, Brown"...

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.

Solutions

Expert Solution

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
domian <-"IloveR.edu" # creating the domain
name =tolower(name) # COnverting Names into Lowercase for username
splitted<-strsplit(name, ", ") #Splitting first Name and and Last Name
lists <- matrix(unlist(splitted), ncol=2, byrow=TRUE) # creating a matrix of fname and lname
df <-as.data.frame(lists) # Converting them to data frame
colnames(df) <-c("First Name","Last Name") # Column Names
df
email=c() # A vector named email

#Iterating over daataframe and creating email ids
for (i in 1:nrow(df)){
email[i]=paste(df$`First Name`[i],".",df$`Last Name`[i],"@",domain)
# concatenating names and storing in email vector
}
email
write(email, file = "email.txt", sep = "\n") # Writing into a file

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"

Related Solutions

C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the...
C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the range of 0 to 100. There may be repeats. The numbers must not be ordered/sorted. The task is to find and print the two smallest numbers. You must accomplish this task without sorting the file and without using arrays for any purpose. It is possible that the smallest numbers are repeated – you should print the number of occurrences of the two smallest numbers....
1. create a .txt file and call it fruits.txt, add the following items to the file...
1. create a .txt file and call it fruits.txt, add the following items to the file Apple Banana Peach Strawberry Watermelon Kiwi Grape _______ 2. Write a program that does the following: - Reads the fruit.txt - Converts the contents into all uppercase - Writes the uppercased values into a text file called "UpperFruit.txt" OUTPUT SHOULD BE: APPLE BANANA PEACH STRAWBERRY WATERMELON KIWI GRAPE
Create a c++ program with this requirements: Create an input file using notepad ( .txt )...
Create a c++ program with this requirements: Create an input file using notepad ( .txt ) . When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File”...
how to create a script file on puTTy script pp1.txt
how to create a script file on puTTy script pp1.txt
Create a c++ program that: Create an input file using notepad ( .txt ). When testing...
Create a c++ program that: Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker. Input date...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in...
Create a cronjob which does the following tasks 1.) create a file named <yourname>.txt 2.) in the 35th minute of the hour change the permission to 755 3.) Create a shell script named first.sh in which you print your name and redirect the output by 45th minute of the hour to the text file
APPLIED STATISTICS 2 USE R CODE! SHOW R CODE Use data file RecordMath2526.txt, to produce a...
APPLIED STATISTICS 2 USE R CODE! SHOW R CODE Use data file RecordMath2526.txt, to produce a plot graph with Exam1 as x, Exam2 as y, use Gender as color, and Hw1 as pch. RecordMath2526 information Index Gender Hw1 Hw2 Hw3 Exam1 Hw4 Exam2 Hw5 Hw6 Hw7 Final 1 F 9 6 8 60 7 82 10 10 9 69 2 M 10 10 10 94 9 98 10 10 8 91 3 M 9 10 8 79 9 55 10...
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with...
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with following information: 1,2,3,4,5 red,blue,green,yellow,orange left, right,front, back 2. After having program read the .txt file, output the above information in categories of Symbol, Token Type, and Count : Example: Symbol---Token Type (data type)----Count (how many times symbol appeared in .txt file) =========================================================================== 1 ----digit ----1 2 ----digit ----1 red ----color ----1 blue ----color ----1 left ----direction ----1 right ----direction    ----1
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with...
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with following information: 1,2,3,4,5 red,blue,green,yellow,orange left, right,front, back 2. After having program read the .txt file, output the above information in categories of Symbol, Token Type, and Count : Example: Symbol---Token Type (data type)----Count (how many times symbol appeared in .txt file) =========================================================================== 1 ----digit ----1 2 ----digit ----1 red ----color ----1 blue ----color ----1 left ----direction ----1 right ----direction    ----1
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does...
(Write/read data) Write a Program in BlueJ to create a file name Excersise12_15.txt if it does not exist. Write 100 integers created randomly into the file using text I/O. Integers are separated by spaces in the file. Read data back from the file and display the data in increasing order. After writing the file to disk, the input file should be read into an array, sorted using the static Arrays.sort() method from the Java API and then displayed in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT