0

I have two columns in my dataset in R studio right now: one is "experience level", which contains four different two letter abbreviations ("SE", "MI", "EX", "EN") related to the experience level of an employee. The second column is "salary", which is the employee's salary in USD. How can I create a data frame or sort the data by a specific experience level, such as showing only salaries that are a part of "EN" employees?

I am not sure where to start even. Have tried using group_by but to no avail.

M.Viking
  • 5,067
  • 4
  • 17
  • 33
  • This is what the data looks like as well if it helps: https://imgur.com/heDUNW9 – Erik TG Dec 18 '22 at 00:18
  • 2
    Rather than posting an image of the data, it's much better to post code to create the data as part of your question. Pick a few representative rows (or fake them!) and use `dput()`. We can run that and use it to answer your question. Without that, answers are less likely to be helpful to you. – user2554330 Dec 18 '22 at 00:25

1 Answers1

0

Showing "only" salaries that are part of a group, can be done with filter()

Sorting can be done with the arrange() function

library(tidyverse)
df %>%
   filter(experience=="EN") %>% # filters to only EN 
   arrange(desc(salary)) #sort/arrange the salary data, descending (high to low)
M.Viking
  • 5,067
  • 4
  • 17
  • 33