0
library(ggmosaic)
library(dplyr)
library(purrr)
library(tidyr)
library(broom)
library(tibble)
はコードの下使用して、私はきちんとtibble両方出力する機能だけでなく、ggplotをしたいと思います。私は関数内で複数のものを返すために "return"を使う方法がわかりません。機能で複数のオブジェクトを返す - TidyのChisq.Test TibbleとGgplot
私は他のいくつかのバリエーションを試してみたので、任意のヘルプは次のようになり
Chifun<-function(var){
df<-happy%>%select(-id,-year,-age,-wtssall)%>% map(~chisq.test(.x,happy[,var]))
%>%tibble(names=names(.),data=.)%>%
mutate(stats=map(data,tidy))%>%unnest(stats)
return(df)
GG<-function(var){ggplot(df)+
geom_col(aes_string(x="names",y="p.value"))
return(GG)
}
}
... ...
Chifun<-function(var){
df<-happy%>%select(-id,-year,-age,-wtssall)%>%
map(~chisq.test(.x,happy[,var]))%>%
tibble(names=names(.),data=.)%>%
mutate(stats=map(data,tidy))%>%unnest(stats)
GG<-ggplot(df)+ geom_col(aes_string(x="names",y="p.value"))
return(df,GG)}
...だけでなく、これをこのような何かを試してみました感謝。
、GG = GG)) 'である。 – echasnovski