0% found this document useful (0 votes)
2 views1 page

R Data Frame: Employee Salary Calculation

The document outlines the steps to create a data frame in R with employee details including ID, name, and salary. It then adds a bonus column to the data frame and calculates the total salary by summing the salary and bonus for each employee. Finally, it prints the updated data frame at each step.

Uploaded by

Charu Saxena
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

R Data Frame: Employee Salary Calculation

The document outlines the steps to create a data frame in R with employee details including ID, name, and salary. It then adds a bonus column to the data frame and calculates the total salary by summing the salary and bonus for each employee. Finally, it prints the updated data frame at each step.

Uploaded by

Charu Saxena
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Step 1: Create the Data Frame

employee_id <- c(101, 102, 103)

employee_name <- c("Amit", "Neha", "Rohit")

salary <- c(40000, 45000, 50000)

employee_df <- [Link](employee_id, employee_name, salary)

print(employee_df)

Step 2: Add Bonus Column

employee_df$bonus <- c(5000, 6000, 7000)

print(employee_df)

Step 3: Calculate Total Salary

employee_df$total_salary <- employee_df$salary + employee_df$bonus

print(employee_df)

You might also like