I am trying to calculate mean salary for every job title from a data set which has 2159 job titles and convert into a list. My code
> for (i in 1:length(unique(sfs$JobTitle))) {
a<-print(paste((sfs$JobTitle[[i]])))
b<-print(paste((mean(sfs$BasePay[[i]]))))
ms<-list(a,b)
}
Also tried
for (i in 1:length(unique(sfs$JobTitle))) { ms<-matrix((sfs$JobTitle[[i]]),(mean(sfs$BasePay[[i]]))) }
The output I am getting is a list of 2 elements only. Can you guys help. Thanks