Jump to content

Using a Data Table as a parameter in a R script/Data Function


Jung Choi

Recommended Posts

Hi everyone,

I'm currently working on transforming a data table via a data function (R script) and I'm not sure how to go about using a separate data table as a parameter within that data function (R script). Would someone be able to point me in the right direction What I ultimately want to do is join the data table I'm transforming with the data table I call as a parameter. Thank you in advance!

Link to comment
Share on other sites

Hi SFLearner,

 

You should be able to pull that off with a single data table; the one you start with (be)for(e) the transformation.

Within the data function, when you execute the R code, you can write the outcome of the transformation to a new data table.

You would then end up with 2 data tables that you can join together in Spotfire.

Kind regards,

David Boot-Olazabal

Link to comment
Share on other sites

Hi David, 

 

Really appreciate your reply! So one of the tables is an excel file on my local drive while the other is a table I import from a database. When I join the two tables into a new table, will that join happen everytime I open up the Spotfire analysis or once the join happened, is that the final version The excel file willl be updated periodically so I want to make sure the join will be updated as well. This is the reason I was thinking of possibly incorporating it into a data function that transforms the final data table every time it's loaded but if I can join the two tables without using a data function and the join is updated/refreshed whenever the files are updated, that would be awesome. Please let me know!

Link to comment
Share on other sites

Hi SFLearner,

If you have the join, it will be there whenever you open the dashboard.

But, at the same time as your dashboard opens, the data function/R code should also reload the data table and do the transformation into that new data table. Now that process could 'kill' the join (not certain of it).

What you can do, is to first create the structure in the dashboard (1 data table, the second data table from the R script as a new data table and then the join between the two data tables). Then, when done and if it looks fine, you can change the setting for the R script so it overwrites the 2nd data table instead of creating a new one. If you overwrite the data table again and again, I think the join would be there whenever you open the dashboard, including the loading/transformation process.

Kind regards,

David

Link to comment
Share on other sites

SFlearner, you only have to use the feature to "add columns". You can add any transformation to the additional table before you add the columns to the old table. For example, the source for your new columns is an excel table. Load this table, add some transformation, than merge by your key columns. You can pick the join method in when you finally add the columns. As long as the setting for this data source (here the excel file) is set to "always new data", it will automatically reload when you open the dashboard. You can do all if this in the data canvas. I think you don't need any data function for your task.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...