Giter VIP home page Giter VIP logo

Comments (10)

JasperHG90 avatar JasperHG90 commented on July 21, 2024

Hi Delkine,

I'm not sure what you mean when you refer to 'the script'. It would help to see it.

Does qualtRics work stand-alone? Or does it fail across the board?

I just tested it with newest version of R and it works for me.

from qualtrics.

Delkine avatar Delkine commented on July 21, 2024

Jasper,
#Here is the Script that has worked until last Friday. I've deleted some irrelevant code (API Key, Instructions etc.)

This script is use to Get Survey Responses from Qualtrics API.

Start

Set Working Directory to R Scripts

setwd("c:/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data")

library(qualtRics)
Found a .qualtRics.yml configuration file in c:/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data. Using these credentials.

surveys <- getSurveys()
#Read lastResponseId for the saved value from previous runs.
lastId.rds <-readRDS("lastId.rds")

Provide surveys$id (number that is in brackets) with one associated with chosen survey & save_dir location to one of your choosing

mysurvey <- getSurvey(surveyID = surveys$id[9],

  •                   save_dir = "/users/del/dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/",
    
  •                   lastResponseId = lastId.rds,
    
  •                   verbose=TRUE,
    
  •                   uselabels=FALSE,
    
  •                   force_request = TRUE)
    

#HERE IS THE ERROR
Error in qualtRicsResponseCodes(res, raw = raw) :
Qualtrics API raised a bad request (400) error - Please report this on https://github.com/JasperHG90/qualtRics/issues

#Get new lastResponseId from current download for next iteration
lastId.rds <- tail(mysurvey$ResponseID,1)
#THIS ERROR IS NEW TOO
Error in tail(mysurvey$ResponseID, 1) : object 'mysurvey' not found
#Save new lastResponseId for next iteration
saveRDS(lastId.rds, file = "lastId.rds")

File names and locations can be changed to suit your needs.

mysurvey <- readRDS(file = "/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds") # Initial file is output as *.RDS file.
write.csv(mysurvey, file = "/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/mshare2.df.csv", row.names = FALSE) # RDS file is converted to csv.

End

from qualtrics.

JasperHG90 avatar JasperHG90 commented on July 21, 2024

Hi Del,

May I ask why you closed this thread? Was your issue solved?

J.

from qualtrics.

Delkine avatar Delkine commented on July 21, 2024

Sorry, I didn't intend to close it. It should still be open. Do I need to do something to open it back up again?

from qualtrics.

JasperHG90 avatar JasperHG90 commented on July 21, 2024

To me, this looks like an error caused by passing a bad response id .

Try the following:

  1. try to download your survey without passing the responseId
  2. if this works, take a random responseId from the survey and use it to download your results again
  3. check the RDS file in which your responseId is stored. See if it is malformed in any way.
  4. in any case, if step 2) works out for you try rebooting your script with the new latest responseId

J.

from qualtrics.

Delkine avatar Delkine commented on July 21, 2024

from qualtrics.

JasperHG90 avatar JasperHG90 commented on July 21, 2024

Hi Del,

Could you let me know if this is still an issue for you?

Thanks.

J.

from qualtrics.

Delkine avatar Delkine commented on July 21, 2024

from qualtrics.

Delkine avatar Delkine commented on July 21, 2024

Jasper,
I'm still getting inconsistent behavior from this code. I hope you can point me in the right direction. I thought everything was running as planned but then I get an error. I get this error off and on but not consistently.
This code is run from RStudio and is scheduled to run every night automatically.

Code starts below this line.


setwd("c:/users/del/Qualtrics Data")

library(qualtRics)
registerOptions()

surveys <- getSurveys()

#lastid1.rds <-"R_RISFrOdBtIR1kyZ" ## Remove comment marks in col. 1 when running & no lastid has been previously stored in wd.
## Previously stored lastid will be overwritten. Replace value in " " with responseid desired.

## Save lastid1.rds to a file to store initial value and subsequent values for lastResponseId

#saveRDS(lastid1.rds, file="lastid1.rds") ## Remove comment mark in col. 1 when running & no lastid has been previouly stored in wd.

## Read lastResponseId for the saved value from previous runs.

lastId2.rds <-readRDS("c:/users/del/Qualtrics Data/lastId1.rds")

#Comment
At this point I get the following error:

Error in readRDS("c:/users/del/Qualtrics Data/lastId1.rds") :
error reading from connection
#Comment
The file exists on the wd and it has a valid responseID saved in it.
Once this error occurs there are several other errors as code runs as having this value is the needed

## Provide surveys$id (number that is in brackets) with one associated with chosen survey 

mysurvey <- getSurvey(surveyID = surveys$id[9],
save_dir = "/users/del/Qualtrics Data/",
lastResponseId = lastId2.rds,
verbose=TRUE,
uselabels=FALSE,
force_request = TRUE)

## Get new lastResponseId from current download for next iteration

lastId1.rds <- tail(mysurvey$ResponseID,1)

## Save new lastResponseId for next iteration

saveRDS(lastId1.rds, file = "c:/users/del/Qualtrics Data/lastId1.rds")

mysurvey <- readRDS(file = "c:/users/del/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds") # Initial file is output as *.RDS file.
write.csv(mysurvey, file = "c:/users/del/Qualtrics Data/mshare2.df.csv", row.names = FALSE) # RDS file is converted to csv.

from qualtrics.

JasperHG90 avatar JasperHG90 commented on July 21, 2024

Hi Del,

I want to help you, but as I'm sure you understand, it's close to impossible for me to debug your code from a distance. This is especially true since the error you are experiencing does not occur in my package, but in a generic R function.

First, a couple of things that, in general, are problematic about your code:

  1. Don't use spaces in folder names, use underscores: "c:/users/del/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds" --> "c:/users/del/Qualtrics_Data/SV_1ZVShEVtp6thqkd.rds"
  2. Don't use something like '.df.csv' for your filenames. Names that start with '.' are reserved for the operating system and are used to denote file extension. Again, use underscores. --> 'myfile_df.csv'

Now, I don't know about your current setup, but try the following:

  • Update R to the latest version. Make sure that you have only 1 version of R installed and that your system uses the latest R version when it runs the script (instead of a legacy version of R). If you're not sure about this, remove R from your computer entirely, download the latest version and install again.
  • Download RStudio, open your script and run your code line by line (make sure to change the spaces to the file name).
  • Use a different format to save your lastResponseId in. Instead of RDS, you can save it as a csv file, a plain text file, a yml file and so one (although csv would be easiest given that you know how to write and load it).

Hope that helps.

I'm closing this issue because the error is not related to the qualtRics package.

Best,

Jasper.

from qualtrics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.