Skip to content

Instantly share code, notes, and snippets.

@leeper
Created April 13, 2015 10:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeper/c05536887d781e535fb0 to your computer and use it in GitHub Desktop.
Save leeper/c05536887d781e535fb0 to your computer and use it in GitHub Desktop.
Function read data from a Qualtrics-generated CSV file
read.qualtrics.csv <- function(filename, stringsAsFactors = FALSE, ...) {
n <- read.csv(filename, nrows = 1, stringsAsFactors = FALSE)
dat <- read.csv(filename, header = FALSE, skip = 2, stringsAsFactors = stringsAsFactors, ...)
names(dat) <- names(n)
names(dat)[1:10] <- n[1,1:10]
for(i in seq_along(dat)) {
attr(dat[,i], "question") <- n[1,i]
}
dat
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment