Q2 (a)
The project manager at XYZ Ltd., Ms. Meera, maintains the details of all active projects.
She has organized the information in the following table:
Project Id | Project Name | Budget | Status
1 | CRM Implementation | 120000 | In Progress
2 | Cloud Infrastructure | 180000 | Completed
3 | Network Upgrade | 60000 | Not Started
4 | E-Commerce Platform | 220000 | Completed
5 | Data Analytics | 90000 | In Progress
------------------------------------------------------------
i) Create a Data Frame in R for the above project data and display the output.
R Script:
# Create vectors for each column
ProjectId <- c(1, 2, 3, 4, 5)
ProjectName <- c("CRM Implementation", "Cloud Infrastructure",
"Network Upgrade", "E-Commerce Platform", "Data Analytics")
Budget <- c(120000, 180000, 60000, 220000, 90000)
Status <- c("In Progress", "Completed", "Not Started", "Completed", "In Progress")
# Create the data frame
project_df <- [Link](ProjectId, ProjectName, Budget, Status)
# Display the data frame
print(project_df)
Output (Exam-style):
ProjectId | ProjectName | Budget | Status
1 | CRM Implementation | 120000 | In Progress
2 | Cloud Infrastructure | 180000 | Completed
3 | Network Upgrade | 60000 | Not Started
4 | E-Commerce Platform | 220000 | Completed
5 | Data Analytics | 90000 | In Progress
------------------------------------------------------------
ii) Ms. Meera has approved 2 new projects. Add them to the existing data frame and display the
updated information.
Project Id | Project Name | Budget | Status
6 | UX Research | 160000 | Not Started
7 | Cloud Integration | 190000 | Not Started
R Script:
# New project data
new_projects <- [Link](
ProjectId = c(6, 7),
ProjectName = c("UX Research", "Cloud Integration"),
Budget = c(160000, 190000),
Status = c("Not Started", "Not Started")
)
# Combine both data frames using rbind()
updated_project_df <- rbind(project_df, new_projects)
# Display updated data
print(updated_project_df)
Output:
ProjectId | ProjectName | Budget | Status
1 | CRM Implementation | 120000 | In Progress
2 | Cloud Infrastructure | 180000 | Completed
3 | Network Upgrade | 60000 | Not Started
4 | E-Commerce Platform | 220000 | Completed
5 | Data Analytics | 90000 | In Progress
6 | UX Research | 160000 | Not Started
7 | Cloud Integration | 190000 | Not Started
------------------------------------------------------------
Conclusion:
- The [Link]() function is used to create tabular data in R.
- The rbind() function is used to add new rows (records) to an existing data frame.
- This allows Ms. Meera to easily update and maintain project details in R.