My df has three variables. NSCore , NS_Group (which is categorical, have three levels Low,High,Very High). SOC(Which is categorical having three levels SOC1,SOC2 and SOC3). Looking like that.
df
NScore NS_group SOC
1 Low SOC1
2 Low SOC2
3 High SOC3
4 High SOC2
5 Very High SOC3
I am using following code in R But this is giving me frequency of NScore against NS_group and SOC . But i want to see the mean of NScore against these two.
`tab1 <- with(df, table(df$NS_group,df$SOC))
I want MEAN OF NScore (Not the frequency) against these two categories something as follows.
SOC1 SOC2 SOC3
Low 1 1 2
High 1 2 1
VeryHigh 1 1 2
p.s All the values are hypothtical just to explain what i am asking