I am trying to summarise the mean, sd etc for a number of different columns (variables) in my dataset. I have coded my own summarise function to return exactly what I need and am using sapply
to apply this function to all the variables at once. It works fine, however the dataframe that is returned has no column names and I cannot seem to even rename them using a column number reference - aka they seem impossible to use in any way.
My code is below- as I am just finding summary statistics, I would like to just keen the same column (variable) names, with 4 rows (mean, sd, min, max). Is there any way at all to do this (even a slow way where I manually change the names of the columns)
#GENERATING DESCRIPTIVE STATISTICS
sfsum= function(x){
mean=mean(x)
sd=sd(x)
min=min(x)
max=max(x)
return(c(mean,sd,min,max))
}
#
c= list(sfbalanced$age_child, sfbalanced$earnings_child,
sfbalanced$logchildinc ,sfbalanced$p_inc84, sfbalanced$login84,
sfbalanced$p_inc85, sfbalanced$login85, sfbalanced$p_inc86,
sfbalanced$login86, sfbalanced$p_inc87, sfbalanced$login87,
sfbalanced$p_inc88, sfbalanced$login88)
summ=sapply(c,sfsum)
names(summ)
NULL