Alteryx Designer Discussions

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

How to name output fields in R tool

jmelcher
6 - Meteoroid
I have been reading the help guide for the R tool but I still can't get it to work.  What are the steps to do so that your outputs (1 and 2) for R are named a certain thing?

I have tried to have them output then join them immediately after and rename them there, but what happens is it seems the name is dynamic based on the value that it calculates.  And sometimes it will not be able to rename itself since it is different.

If you can give me any help that would be great
 
6 REPLIES 6
kane_glendenning
10 - Fireball
Hi Jacob,

Are you talking about the fields? If your output is just one field, then you can use a dynamic rename tool with formula selecting all fields and the formula will just be "<enter name here>".

If there is a table coming out with fields then the easiest way is to rename the columns before they come out with the names command

names(datatable) <- c("Field1Name", "Field2Name")
write.Alteryx(datatable, 1)

Let me know if this doesn't answer your question,
Kane
jmelcher
6 - Meteoroid
It is only one single thing coming out at a time (granted 2 outputs).  The issue I think with the dynamic rename tool (I could be wrong), is that the field name changes sometimes but not always.  It is x###, where the ### is the value.  So if if there is no unknown or dynamic value will it skip that field?

Because if I select the first field that just ran, lets say x123. And rename that to "low-threshold", it will work. But if next run it changes to x124, it won't be able to find x123 and won't rename the new x124.

Hopefully that makes sense. 
kane_glendenning
10 - Fireball
In the example that you give, when you configure the dynamic rename you will have 2 options for fields, x123 & dynamic or unknown. Select both these, so that your formula will apply to the new field name that comes through.
jmelcher
6 - Meteoroid
Okay Thank you, I didn't know if you could only chose one or if it would mess up if the top "pick" didn't work.  

But do you know of anyone way to have the name changed out of R by itself?  This just seems like a work around (albeit it works), but I feel like there should be a better way of doing it. 
kane_glendenning
10 - Fireball
I'm not sure that I understand what you mean by "have the name changed out of R by itself". This method will change all fields to your text entered in the formula. If there happens to be extra fields come out then they will automatically be assigned the name with a 1 on the end and you'll receive a warning in the output. If you have dynamic fields coming through, then it makes sense to use the dynamic rename tool.

If you happened to have 2 dynamic field names come out of the one R output and you really wanted to rename them after they come out, then you can use a dynamic select tool to select one field at a time by field position, followed by the above method.

I don't see this as a workaround as you have a dynamic field name and you want to select it for rename, but you can't select it by name... so you select the dynamic fields. 

Please let me know if I've misunderstood the issue,
Kane
jmelcher
6 - Meteoroid
Well I ended up just turning the two values that I was outputting before into one table because that fixed all my problems. I just wasn't sure if there was a way to name the value coming out of R without having to dynamically rename it.  But I guess you should just turn it into a table with one column and rename it there is the solution.

Thanks!
Labels