r - Outlier removal from list of grouped values

r - Outlier removal from list of grouped values



I wanted to run t-tests in a dataset that have two factors: A and B. I've got this working but without removing the outliers.



My idea is to remove values using the 1.5*IQR criteria. I've could not figure out how to do this following the dyplyr way (?).



Here is what I have:


wallSize %>%
select(Time, A, B) %>%
gather(key = variable, value = value, -A, -B) %>%
group_by(A, B, variable) %>%
summarise(value = list(value)) %>%
spread(A, value) %>%
group_by(variable) %>%
mutate(p_value = t.test(unlist(True), unlist(False), paired=TRUE)$p.value,
t_value = t.test(unlist(True), unlist(False), paired=TRUE)$statistic)))



I think I should do the outlier removal after the spread for each of the 6 lists individually but I can't figure it out how... Any suggestions from the R masters?



Cheers



EDIT: Sample data
head of the frame before grouping:


head


Display Change Comp TargetType TotalTime SelectionTime Score
<chr> <chr> <chr> <int> <dbl> <dbl> <int>
1 Wall Shape False 1 62.2 53.7 4
2 Wall Shape False 2 14.1 12.6 5
3 Wall Shape True 0 26.3 23.0 5
4 Wall Shape True 0 20.3 14.7 5
5 Wall Shape True 1 23.3 21.6 5
6 Wall Shape False 2 6.55 5.17 5



after grouping:


TargetType variable False True
<int> <chr> <list> <list>
1 0 SelectionTime <dbl [28]> <dbl [28]>
2 1 SelectionTime <dbl [28]> <dbl [28]>
3 2 SelectionTime <dbl [28]> <dbl [28]>






Could you please provide an example of your data or data like it? stackoverflow.com/questions/5963269/…

– Jon Spring
Sep 13 '18 at 5:08






Hi Jon, I've edit the question with the head of the df and the output of the grouped data. Thanks for trying to help. People are quick to downvote =/

– Juliano Franz
Sep 13 '18 at 10:46




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)