Skip to main content
Question

How can I use an FME list in RCaller without getting an error?


I am trying to set a variable in the RCaller console. For example...

type = (List$my_list{}.type)

but it returns the error Error: unexpected '{' in "type = (List$my_list{"

Is there some trick to using FME lists which contain braces in the RCaller script console?

Normally you can get around this special character issue in R using one of the solutions in this Stack Overflow post - using backticks `` and/or aes_string(). Or just using colnames() to rename the data frame column names and then referencing those.

However, I just ran a quick test and it appears our RCaller does not accept FME lists as input. They come in as NA values in this test workspace I created. I will check with our developers if this is true and report back.

rcaller-fme-lists.fmw


Hi @r5. I have looked into it a bit further. FME can access the list within the RCaller, but you have to enumerate all the possible list values, e.g. 

list{0}
list{1}
, etc., in your columns (RCaller > Inputs > Columns > Name), rather than just writing 
list{}

You could still run into issues with the 

{}
 in variable names in R. But that can be addressed in a number of ways, including those I mentioned in my previous post.

Does that help with your specific case? Would it be onerous to enumerate your list? Will it always be the same length? If you want to avoid managing the 

{}
 issue in the RCaller, you could enumerate your list and rename each attribute in an AttributeManager before the features enter the RCaller. Or depending on the scenario, use a ListExploder to turn the list entries into features. If your list could vary in length/content/schema, then it's a more complex issue. If you provide some details about your use case (a minimal reproducible example in a workspace template would be great), I can see if there is anything we can do to make it easier.

Reply