I'm not able to import a TSV survey data file in R due to an error (the file is exported from Qualtrics as TSV). This is my code:
library(readr)
df <- read_tsv('example_data_from_qualtrics.tsv')
Running the code results in this error message:
Error in vroom_(file, delim = delim %||% col_types$delim, col_names = col_names, :
embedded nul in string: 'S\0t\0a\0r\0t\0D\0a\0t\0e'
Maybe an encoding issue. I couldn't find a solution yet.
EDIT: here's some sample data:
(see it in sublime text, notepad ).
readr::read_tsv('~/Downloads/example_data_from_qualtrics.tsv',
locale = readr::locale(encoding = "UTF-16LE"))
I think it's better to delete lines 2 and 3 in your file before importing it. These lines could be read in another step to have label of your columns, for instance with readr::read_tsv(.., n_max = 2).
Then readr will guess column types more precisely.
To have answers by rows, you can pivot your data by user:
u <- readr::read_tsv('~/Downloads/example_data_from_qualtrics.tsv', locale = readr::locale(encoding = "UTF-16LE"))
v <- u %>% tidyr::gather(var, val, - IPAddress, - ResponseId, - UserLanguage, - DistributionChannel,
- StartDate, - EndDate, - RecordedDate,
- RecipientLastName, - RecipientFirstName, - RecipientEmail, - ExternalReference,
- Status, - Progress, - `Duration (in seconds)`, - Finished, - LocationLatitude, -LocationLongitude)
To have labels (and questions of the survey), you can do:
u <- readr::read_tsv('~/Downloads/example_data_from_qualtrics.tsv',
locale = readr::locale(encoding = "UTF-16LE"), n_max = 3)
v <- u %>%
filter(row_number() %in% c(1,3)) %>%
tidyr::gather(var, label_question)




