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. R). 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, e.g., if your students id is a12345, id should be 12345.
If applicable, create an id2 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 5 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 1Y,2Y,3Y, Y1, Y2, Y3 and must have the levels Y1,Y2 and Y3.
c) Variable stats currently has the levels N, No, Y, Yes and must have the levels Y and N.
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:
1
set.seed (id)
fellows - fellows[sample(1:nrow(fellows)),]
Write this data frame into a file named fellows.csv, making sure to not include the row labels in the file.
Submit the script (roster.R) and the CSV file (fellows.csv)
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 (e.g., 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!