Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

r - Dplyr summarise()

I was wondering why summarise() is returning a table, while I was expecting a row? Here's the code:

car %>% group_by() %>%
  mutate(grandmean = mean(Puntuacion, na.rm = TRUE)) %>%
  mutate(SST1 =  sum ((Puntuacion - grandmean)^2)) %>%
  group_by(Tipo_vehiculo) %>%
  mutate(groupmean = mean(Puntuacion, na.rm = TRUE)) %>%
  mutate(vec_sum = ((Puntuacion - groupmean)^2)) %>%
  group_by() %>%
  mutate(SSW1 = sum(vec_sum)) %>%
  mutate(SSB1 = SST1 - SSW1) %>%
  summarise(SST2 = SST1, SSB2 = SSB1, SSW2 = SSW1, F = (SSB1 / (m-1)) / (SSW1/ (n-m)))

Thanks for your help!

** even though Im still not sure how to properly solve it, i solved it adding:

%>% summarise(SST = SST2[1], SSB = SSB2[1], SSW = SSW2[1], F_value = F[1])
question from:https://stackoverflow.com/questions/65851713/dplyr-summarise

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...