I am using the package qualtRics in TERR in Spotfire to pull in data directly from specific surveys in Qualtrics. The code I am using is:

registerApiKey(API.TOKEN = "xxxx") 
df <- getSurvey(surveyID = "xxxx", 
                root_url = "https://az1.qualtrics.com", verbose = TRUE)

My output df is a data table. I have 2 different surveys that I am pulling in 4 different times, 2 of those times I am unpivoting data, for a total of 4 data tables.
I want to be able to refresh this data. If I click Reload Data or try to refresh each table individually, nothing happens. I'm assuming I need to add some code that refreshes the data function (?), and I am trying to avoid replacing the data tables each time because, for 2 of those, I have to manually select which columns I am unpivoting (and I have 75+ columns).

Is there a way I can accomplish what I'm looking for? I am a beginner Spotfire/R user, so I am learning as I go!

2

There are 2 best solutions below

1
On

Instead of using spotfire's pivot/unpivot, you can try doing the unpivot within the R code of the data function.

0
On

I am not able to reply to your question as i dont have enough permission so keeping it as separate answer. Replacing table each time is good idea, By This you can fix your no of columns for pivoting/UnPivoting.

------R Code

row <- data.frame(Data_Points = nrows, Col1 = col1, Col2 = col2, YStart = y1, YEnd = y2)

row <- cbind(df, row)

return(row)

And also you can list your fix columns into DocumentProperty and loop it into your DataFunction.