0

Thank you! enter image description here

blaze
  • 57
  • 1
  • 3
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Pictures are not helpful because we have no idea what the underlying object really is. – MrFlick Sep 24 '19 at 01:12
  • Related, but not a duplicate: https://stackoverflow.com/questions/28873323/removing-attributes-of-columns-in-data-frames-on-multilevel-lists-in-r – Kevin Troy Sep 24 '19 at 15:38

1 Answers1

2

The labels are stored as attributes of the individual vectors in the tibble returned by qualtRics::fetch_survey(). You can modify the label for an individual column this way:

attr(tibble_name$column_name, "label") <- new_value_here

(If you want to remove the label entirely, you can set the new value to NULL.)

For removing multiple labels, I recommend the sjlabelled package. To remove all labels entirely:

tibble_name %>% 
  sjlabelled::remove_all_labels() %>% 
  tibble()    # without this, results will be cast as a list

To remove labels only from variables that meet certain tidyselect criteria:

tibble_name %>% 
  sjlabelled::remove_label(starts_with("Recipient")) %>% 
  tibble()

To modify labels or add new ones, sjlabelled also has add_labels(), replace_labels(), and set_labels() functions -- see the documentation.

Please note that, for Qualtrics datasets in particular, removing the labels destroys information -- someone with access only to the dataset and not to the original survey instrument may not be able to determine what the various columns represent without them. (The screenshot shows trivial examples where the labels are the same as the column names, but for the question response data it's different.)

Kevin Troy
  • 412
  • 4
  • 13
  • how to we keep the labels as a separate row. As in the image by OP, there are 2 labels for each column...how do we separate them out ? – user5249203 Apr 02 '21 at 19:39