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

Potential enhancement/feature in Rtools

frankzhang
5 - Atom

Just realized when read alteryx input into R tools, the column names will change if it doesn't comply with certain  rules.

 

My guess is that the issue is somewhere in the Alteryx backend R code have 

 

data.frame(...,check.names = TRUE)

 

Or other problems with 

 

check.names

 

 

I feel it is a bit unexpected. Is it possible to fix or have other ways to keep column names of input?

 

image.pngimage.png

 

 

2 REPLIES 2
danilang
19 - Altair
19 - Altair

Hi @frankzhang 

 

This behaviour stems from the fact that R has problems referencing column names that contain spaces in DataFrames.  To get around this, column names are cleaned on entry to remove any special characters using the equivalent of make.names().  The tidyverse tibbles version of the dataframe gets around this issue by enclosing offending column names with back tick characters `column name`, but it looks like the R tool in Alteryx hasn't taken advantage of this feature.  

 

You can get around the behaviour by ensuring that the column names are cleaned before entry and then resetting them after output like this.  This strategy avoids getting any surprises from the internal rename

 

w.png

 

This is a simple example that only deals with spaces, but the concept would be valid for more complex scenarios

 

This is a good suggestion, and you should add it to the Ideas forum on the community.  I did a quick search and didn't find anything similar.

 

Dan

frankzhang
5 - Atom

Thanks Dan. Thanks for this workaround solution. I wouldn't expect Alteryx can fix this in a short time..As I guess too many codes dependent on this. At lease they should warn in documentation someplace.

Labels