Hi!
As I am quite new here I would like to get all the help I can get. Sorry if this is the wrong thread. This is about R and Alteryxx
I try to compare medians and as Alteryx from what I know do not have a function for that, I tried to import some R libraries (RVAideMemoire and rcompanion) to try to use the functions Mood medtest and Pairwise Medtest to do so. I have figured out how to get them to run, but I have not figured out how I could make a neat output to some tables. For Mood's medtest it does not matter much since I will only get one R-value, but from the Pairwise Medtest I would like to get the output in order like something like this for the Pairwise Medtest:
Comparison | p.value |
A - B | 0.41... |
A - C | 0.73... |
A - D | 0.73.. |
B - C | 0.31... |
B - D | 1 |
C - D | 1 |
That is very similar to what the program prints in the "Message screen" (see below)
R (1) Comparison p.value p.adjust
R (1) 1 A - B = 0 0.4142 1
R (1) 2 A - C = 0 0.7389 1
R (1) 3 A - D = 0 0.7389 1
R (1) 4 B - C = 0 0.3173 1
R (1) 5 B - D = 0 1 1
R (1) 6 C - D = 0 1 1
Since I am a novice however, I only manage to get the p.values printed out in this fashion (see below), which severely impacts the ability to use the function/R-program for 50+ different examination.
X.0.4142. | X.0.7389. | X.0.7389.1 | X.0.3173. | X.1. | X.1..1 |
0.4142 | 0.7389 | 0.7389 | 0.3173 | 1 | 1 |
Do you have any ideas on how to get to the first table?
Best regards,
an R noob in need
Solved! Go to Solution.
Hi @enylen,tried running it and couldn't get the packages imported into Alteryx; (our security is something else).
However, I did get it running in R-Studio, and I don't see the amount of detail shown in your question...
Did you have any additional code to support what referenced as showing in your "Message screen" and/or the output you managed to get?
Hi!
This is what I did to solve it:
In order to make it work I had to keep the names in the column type without spaces. Otherwise the Alteryx output would not be able to be handled by Regex_replace above. I also kept the names very short. For some strange reason long names would split the output that belonged together (name of pairwise comparison, p value, adjusted p value) into different rows even if they belonged to the same comparison.
Code used:
input.data <- read.Alteryx.First("#1", 5000, mode = "data.frame")
if(!require(rcompanion)){install.packages("rcompanion")}
library(rcompanion)
PT = pairwiseMedianTest(Value ~ Type,
data = input.data,
exact = NULL,
method = "fdr")
# Adjusts p-values for multiple comparisons;
# See ?p.adjust for options
PT #not sure if necessary
ut <- capture.output(PT)
data.out1 <- ut
write.Alteryx(data.out1, nOutput = 1)