community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

R tool and wilcox test

Highlighted

Hello, new to Alteryx here. Having some issues with the R tool

Attached is a sample dataset and workflow.

 

The attached code works great in Rstudio.

For some reason it fails in Alteryx.

Not using anything fancy, just base R.

 

My goal: perform Wilcox test on each variable (column) in my dataset against the "group" variable/column, then output a database of p-values (listed in a column).

 

When I use the alteryx R tool, the p-values result as "0" with an error that reads: "The display value was rounded to 6 decimal places for clarity." Outside of alteryx, with the same dataset, it works fine...

 

Here is the code:

 

data <- read.Alteryx("#1", mode="data.frame")

out <- apply(data[-1], 2, function(x) wilcox.test(x, data$group))

p <- sapply(out, function(x) {
  p <- x$p.value
  n <- outer(rownames(p), colnames(p), paste, sep='v')
  p <- as.vector(p)
  names(p) <- n
  p
})

p <-data.frame(keyName=names(p), value=p, row.names=NULL)

write.Alteryx(p, 1)

 

 Any help would be very much appreciated!

 

 

Update - this was solved by using a select tool and converting the R output to strings

Labels