How to import Qualtrics data (in csv format) into R

戏子无情 提交于 2019-12-01 19:55:08

I use the following code to import data from Qualtrics into R:

library(tidyverse)
filename <- "mydata.csv"
headers = read_csv(filename, col_names = FALSE, n_max = 1)
df = read_csv(filename, skip = 3, col_names = FALSE)
colnames(df)= headers

However, there is one caveat. This method only works when you removed all line breaks when you downloaded your data. (Please see the graph below as to how to do so.) My skip = 3 argument works because I removed all line breaks when I downloaded the data from Qualtrics. It is very probable that the questions you asked in Qualtrics contains multiple lines. It constitutes a problem for R to understand your file in this way. I recommend you to remove all line breaks when you download the data from the website.

Using the method above, R can normally correctly recognise the data structure of most columns, saving yourself a ton of effort to recode yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!