In the DataAnalyst data (from Kaggle), I am trying to show descriptive statistics of Ratings (numeric value) by state (categorical factor). I am able to successfully display everything but the state names which shows up as #s:
m<-aggregate(Rating~state, data=df,mean)
sd<-aggregate(Rating~state, data=df,sd)
n<-aggregate(Rating~state, data=df,length)
##summary descriptive table
(df.des <- cbind(n[,1], n=n[,2], mean=m[,2], sd=round(sd[,2],3),se=round(sd[,2]/sqrt(n[,2]),3)))
For df.des, I understand the n[,1] displays the # col you want. I have tried n[,2] which brings up the number/state. How can I get the table to display the names and not the numbers? P.S. "State" is listed as characters (e.g. CA, NY, IL) and not numbers.
descriptive statistics with numbers instead of state categories