0

I have a dataset with 7 variables, in the 'ds.salaries' dataset.

  • work_year
  • experience_level
  • employment_type
  • job_title
  • salary
  • remote_ratio
  • company_size

I'd like to add a new variable based on the mean found under the experience_level column. Which has 4 groups,

  • entry.level, 29 observations
  • mid.level, 77 observations
  • senior.level, 209 observations
  • executive.level, 15 observations

I'd like the average for each level returned and then add them as a new column to the dataset 'ds.salaries'. This is the line I used to get the average for each level and it runs fine but I can't figure out how to add it to the dataset without wiping away all the other columns. I'm still relatively new to R so any help would be appreciated. Thanks in advance.

ds.salaries %>% 
  group_by(experience_level)
  summarize(avg_salary = mean(salary))
user438383
  • 5,716
  • 8
  • 28
  • 43

0 Answers0