I've previously asked this question: How to add the results of applying a function to an existing data frame?
I thought I could use that as a template and unnest() the results of my oddsratio test to the dataframe.
Here's some numbers
thing<-matrix(c(33,2153,48,2528,1577,30335,66,1916,24,1162,15,910),nrow=6,byrow=T)
colnames(thing)<-c("SM","AE")
rownames(thing)<-c("a","b","c","d","e","f")
oddsratio(thing)
I was hoping that if I did this:
oddsthing<-as.data.frame(thing)
oddsthing<-oddsthing%>%mutate(res=list(oddsratio(thing)))%>%unnest()
But it does not produce the output I was hoping for.
When I write
thing_list<-oddsratio(thing)
I can see four elements in the list: data, measure, p.value, correction
How do I get the measure and the pvalue from the list appended as columns to the right of the SM AE columns?
How do I access the things in the list? I can unnest($res) but that doesnt work either.
I have a feeling I'm almost there....
thnaks!