Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program is R studio. Please help with following questions,Thank you! DATA CLEANING Changing data types for variables Display the structure of the data frame employee.
Program is R studio. Please help with following questions,Thank you!
DATA CLEANING
- Changing data types for variables
- Display the structure of the data frame employee. What is the data type of the gender column?
- If data type is already factor, then skip the next two questions and go to question 14. If the type of the gender column is not factor, change the type of gender column to factor type.
- Display the structure of the data frame employee again. What is the data type of the gender column? Has it been changed to factor? If not, correct your code to change the type of gender column to factor type.
- Display the structure of the data frame employee once more to see the change.
- Display ALL data in employee object (data frame)
- Replacing/Changing values:
- Change the hair color (hcolor) of Nancy to brown
- The birthday (birthyear) of 1993 is recorded for Chloe in row 5. Change 1993 to her age.
- The weights entered for the last three employees are in kilograms. Change these weights to lbs equivalents of: 144, 131, 199
- Display the employee data frame to see that the changes are recorded correctly.
DATA MANIPULATION
- Adding and removing columns
- Remove hcolor column (column 7)
- Add the vectors country and citizen (created in question 1 and 3) as the new columns to employee data frame.
- Display the employee data
- Missing Values (NA)
Checking for missing values (NA). Write the R codes for the following:
- Is there any missing value in employee object?
- How many missing values are there in the employee object?
- Is there any missing value in age variable (column)?
- How many missing values are there in age variable?
- Replace NA value in work column in row 4 (Michael's work) with 14.
- Calculate the mean age - ignore the NA values in the calculation.
- Replace the NA value in age in row 4 (Michael's age) with the mean age value (calculated in 27)
- Omit all other observations with missing values (NA). Note that this will remove all rows containing the missing data. Assign the revised data (without NA data) to a new data frame empComplete
- Display empComplete
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started