Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

R Factors in Alteryx

tcroberts
12 - Quasar

Hi everyone,

 

Coming from an economics and data science background, I'm really enjoying using Alteryx and R together to make the most of my data. In Economics, Categorical data comes up quite a lot in analyses, and is handled in R quite easily using the "Factor" data type. I was wondering how Alteryx would handle this data type coming out of an R Tool, since in R, its treated somewhere between a string and an integer.

 

Cheers,

3 REPLIES 3
asilva
7 - Meteor

Hi,

 

It will actually code the output as a V_WString. I attached a simple workflow.

 

It passed a text input into the R tool as a data frame, then it codes the column as a factor. I then output the data frame to Alteryx and use a Select tool to determine the variable type.

 

Thanks,

 

Tony

 

 

 

 

JohnJPS
15 - Aurora

Hi @tcroberts

Interesting question: it looks like they are treated as strings... although you can control what you want easily enough:

df1 <- read.Alteryx("#1", mode="data.frame")
df2 <- as.data.frame(unclass(df1))
df3 <- as.data.frame(data.matrix(df2))
write.Alteryx(df1,1)
write.Alteryx(df2,2)
write.Alteryx(df3,3)

DF2 should give you a factorized version of DF1, which is sent to output 2... DF3 gives you the numeric values of DF2, sent to output 3.  You can see that output 2 has the string values for the factors; output three will have the numeric values.

Hope that helps!

John

 

 

tcroberts
12 - Quasar

Hmm, thats interesting. Thanks for testing this out! Its good to know that its fairly easy to get the different attributes from a factor.

 

I wonder if there's been any discussion about creating ordinal or categorical variable types within Alteryx. In a recent workflow, I needed to create numeric proxies for a string variable in order to sort and perform some other operations. My job would've been made much easier by a tool that creates an ordinal field, and my mind immediately went to factors in R.

 

Cheers,

 

Labels