Task 3 Import the csv data set “Professorial Salaries” into R:

salary= read.csv("C:\\Users\\69412\\Desktop\\Professorial Salaries.csv")

task 4 Describe the salary data set

4.1 how many variable are there in the “salary” data set?

dim(salary)
## [1] 397   9

4.2 list the variable names

names(salary)
## [1] "ID"            "Rank"          "Discipline"    "Yrs.since.phd"
## [5] "Yrs.service"   "Sex"           "NPubs"         "Ncits"        
## [9] "Salary"

4.3 list the first 6 observations

head(salary)
##   ID      Rank Discipline Yrs.since.phd Yrs.service  Sex NPubs Ncits Salary
## 1  1      Prof          B            19          18 Male    18    50 139750
## 2  2      Prof          B            20          16 Male     3    26 173200
## 3  3  AsstProf          B             4           3 Male     2    50  79750
## 4  4      Prof          B            45          39 Male    17    34 115000
## 5  5      Prof          B            40          41 Male    11    41 141500
## 6  6 AssocProf          B             6           6 Male     6    37  97000

task 5 creat a new variable ” salary.level”

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
salary = salary %>% mutate(salary.level
= case_when(Salary >= 130000~ "High",
Salary>= 100000 & Salary< 130000~ "Medium",
Salary<100000~ "Low"))

task 6 Create a new variable “high.salary”

library(tidyverse)
salary = salary %>% mutate(high.salary
 = case_when(Salary >= 130000~ "1",
 Salary<130000~ "0"))

task 7 create a Create a new variable “salary.aud” as professor’s salaries in AUD (USD/AUD ratio = 1.53).

library(tidyverse)
salary = salary %>% mutate(salary.aud = Salary*1.53)

task 8 Select a subset of participants that includes male professors in the theoretical department who had high salaries.

Men.A.High = salary %>% filter(Sex ==
 "Male", Discipline == "A",
salary.level == "High")

task 9 Create a new data set that includes 4 variables (ID, Rank, Sex and Salary)

library(tidyverse)
var.select2 = salary %>% select(ID, Rank, Salary, Sex)