Hello - I am working with multiple large datasets and am pooling information together in order to create a data frame. However, I would like to add in a column that will allow me to identify the dataset where my observations are coming from. Here is an example that I have created where I was able to add an extra column called 'EmployeeCompany' using the mutate function:
structure(list(EmployeeID = 1:4, EmploymentType = structure(c(2L,
2L, 3L, 1L), .Label = c("Manager", "Mechanic", "Painter"), class = "factor"),
EmployeeCompany = 1:4), class = "data.frame", row.names = c(NA,
-4L))
Is there a way to modify the mutate function so it converts all numerical employee IDs to company name company name Honda, which is the name of my dataset?
Also I would like to repeat this process for a similar data frame but by using Toyota as the employee company. Is there a function that will allow me to merge the two data frames in the end so it looks like this:
EmployeeID | EmploymentType | EmployeeCompany |
---|---|---|
1 | Mechanic | Honda |
2 | Mechanic | Honda |
3 | Painter | Honda |
4 | Manager | Honda |
5 | Painter | Toyota |
6 | Manager | Toyota |
7 | Manager | Toyota |
8 | Mechanic | Toyota |
Thanks!