This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
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,
Solved! Go to Solution.
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
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
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,