Last active
May 12, 2016 01:44
-
-
Save hauselin/299fc906e3de49b73cb2 to your computer and use it in GitHub Desktop.
R functions for Qualtrics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#function to read raw data from Qualtrics | |
cleanQualtrics <- function(csvFile, rowAsHeader, skipRows) { | |
#this function assumes that you have named your | |
#Qualtrics questions properly when setting up the survey; | |
#if questions are properly named, then the first row | |
#will be most informative and suitable for use as column names | |
#read.csv sets header = T by default; stringsAsFactor set to FALSE to ensure strings aren't converted to factors | |
QualtricsRaw <- read.csv(csvFile, header = F, stringsAsFactors = F) | |
#row 1 contains the strings that we'd like to use as column names; select row 1 and turn them into characters | |
colNames <- as.character(QualtricsRaw[rowAsHeader,]) | |
dat <- read.csv(csvFile, header = F, stringsAsFactors = F, | |
col.names = colNames, | |
skip = skipRows) | |
return(dat) #returns the dataframe with proper column names | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment