'How to do a Join and a Loop corectly using R
I have two sets of data that have a column mean_wage
in common, but they are described differently.
First one as 1 (wage), 2, 2.4 ... and the other one as 1256.7 dollars. Because I'm looking at different years I have to make a wage adjustment, so I find it easier to work with salaries this way (1256.7).
How can I create a new column that loops the wage?
Example:
Data_Frame <- data.frame (
Training = c("Enginner", "Lawyer", "Welder", "Teacher", "Police Officer","Street Sweepers"),
Mean_Wage = c(4, 6, 1.2,2,2,1),
Scholarity_years = c("Undergraduate", "MSc", "High School", "Undergraduate", "High School","High School")
)
# Print the data frame
Data_Frame
Data_Frame2 <- data.frame (Mean_Wage = (1256.7))
Data_Frame2
I would like to create a new column that contain the function 1256.7 * 1, 2, 3, 2.4...
I tried to bind cols in my original file and got this error
Can't recycle
..1
(size 12) to match..2
(size 231456...
Backtrace:
- dplyr::bind_cols(Data_Frame, Data_Frame2)
- vctrs::stop_incompatible_size(...)
- vctrs:::stop_incompatible(...)
- vctrs:::stop_vctrs(...)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|