Question: Create a script to put the code you will use to complete this practice ( name it roster. R ) . It is always a
Create a script to put the code you will use to complete this practice name it roster. It is always a good idea to include some comments in the beginning explaining what the script is about, the author and the date.
Create an object named id and assign it the number in your student id eg if your students id is id should be
If applicable, create an id object for a second student. The work should be submitted by the first student only.
Tasks
Read the data into a data frame named roster.
The data set is composed of variables: num student number name, prog, year and stats statistics enrollment
As you can see, the variables prog, year and stats are categorical, but they are encoded inconsistently. For example, a given programme may appear as EGI or LEGI. The same applies to the year and Statistics enrollment.
Start by correcting the inconsistencies. Recode the variables as factors ordered or not, as you see fit:
a Variable prog currently has the levels EER, EGI, IG LEER, LEGI, LIG, LTB TB and must have the levels EER, EGI, IG and TB
b Variable year currently has the levels YYY Y Y Y and must have the levels and
c Variable stats currently has the levels N No Y Yes and must have the levels Y and
In order to accomplish this task, create variables rprog, ryear and rstats as new variables inside the roster data frame
Create a new data frame fellows that includes only the students whose final digit in the student number is the same as yours. Do not include the old variables prog, year and stats in this data frame.
In order to randomize the order of the rows, include the following code in your script and run it:
set.seed id
fellows fellowssample:nrowfellows
Write this data frame into a file named fellows.csv making sure to not include the row labels in the file.
Submit the script rosterR and the CSV file fellowscsv
Recomendations and common mistakes
Always follow the given instructions closely. If you have any question you should ask the teacher.
You must use the specified object names. Objects with a name other than those specified will be ignored and your score will be penalized. The same applies for file names.
If the code need to load data files eg a CSV file the file should be read from the current working directory e should have the original name.
Any attempt to load or use additional packages will probably fail and be marked as an error.
Before submission, the code should be tested on an empty environment with source to verify that it runs without errors. Note that the existence of an error can invalidate all of the code that follows.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
