2
I have the data.frame
:
library(tidyverse)
library(broom)
set.seed(1)
dataset<-as_tibble(matrix(runif(6*30,20,100),ncol=6))
cluster<-kmeans(dataset,3)
dataset$kmeans<-as.factor(cluster[['cluster']])
And I do this analysis:
res1<-dataset%>%
group_by(kmeans)%>%
do(reg=
lm(V1~V2+V3+V4+V5+V6,data=.))%>%
tidy(.,reg)
And everything works out. But when I try to insert the Shapiro-Wilk, the result is not produced by the function broom::tidy
:
shap<-function(x){
lapply(x,shapiro.test)
} # função criada para aplicar o teste nas colunas de um data.frame
res2<-dataset%>%
group_by(kmeans)%>%
do(shapiro=
shap(.[c(1:6)]))%>%
tidy(.,shapiro)
Error: No Tidy method recognized for this list.
What’s the matter?
Both the Hadley Wickham as to Jenny Bryan has lectures that can help.
– Tomás Barcellos