0

I have some columns in a data frame and i want to show the quantity, mean and sd of which column. After that, I want to create a descritive table with the results, but the function doesnt work.

First, i wrote this:

result_df <- data %>%
  group_by(column) %>%
  summarise(Quantidade = n(), #quantity
            Media_Portugues = mean(PROFICIENCIA_LP_SAEB), #mean1
            DP_Portugues = sd(PROFICIENCIA_LP_SAEB), # sd1
            Media_Matematica = mean(PROFICIENCIA_MT_SAEB), #mean2
            DP_Matematica = sd(PROFICIENCIA_MT_SAEB) #sd2
            )

After that, i try to wrote this, but it didnt work...

desc_tab_func <- function(data, column) {
  result_df <- data %>%
  group_by(column) %>%
  summarise(Quantidade = n(), #quantity
            Media_Portugues = mean(PROFICIENCIA_LP_SAEB), #mean1
            DP_Portugues = sd(PROFICIENCIA_LP_SAEB), # sd1
            Media_Matematica = mean(PROFICIENCIA_MT_SAEB), #mean2
            DP_Matematica = sd(PROFICIENCIA_MT_SAEB) #sd2
            )

  return(result_df)
    
}

df_q13 <- desc_tab_func(df_rs_alu, TX_RESP_Q013)
view(df_q13)

When I execute the code, R doesnt show any error message Please, help...

Phil
  • 7,287
  • 3
  • 36
  • 66

0 Answers0