This query is giving me finite observation error, kindly help me to solve this Currently I am trying the below code, I need to find correlation and p value between variable(genolocmean) and variable (genomean) present in genolocmerge data frame.
genoloccorr <- genolocmerge %>% group_by(br_field_id) %>%
do(tidy(cor.test(.$genolocmean,.$genomean)))
Have you tried using the map functions?
genoloccorr <- genolocmerge %>% group_by(br_field_id) %>% summarise(result=map2(genolocmean,genomean,~cor.test(.x,.y)))
This should return a data frame with a column for br_field_id
and a list-column with the output of cor.test()
. If you only need the p-value and correlation, you could modify the ~cor.test(.x,.y)
by attaching an index to pull only what you need.
Without a working dataset I can't test if this code will actually work. If it doesn't please provide a sample dataset so that I can test different ideas.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.