-
-
Save robacc/9b158cce1b14c1219e78 to your computer and use it in GitHub Desktop.
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
| # Set the working directory, not entirely necessary though | |
| setwd("/PATH/TO/WORKING/DIRECTORY/something") | |
| # import likert package | |
| require(likert) | |
| # Output to EPS | |
| postscript("result-plot.eps", onefile=FALSE, horizontal=FALSE, height=2.5) | |
| dataset <- read.table("plot-data.csv", header=TRUE, sep=",") | |
| colnames(dataset)[which(names(dataset)=="column.1")] <- "Column 1" | |
| colnames(dataset)[which(names(dataset)=="column.2")] <- "Column 2" | |
| colnames(dataset)[which(names(dataset)=="column.3")] <- "Column 3" | |
| colnames(dataset)[which(names(dataset)=="column.4")] <- "Column 4" | |
| colnames(dataset)[which(names(dataset)=="column.5")] <- "Column 5" | |
| # create colored plot | |
| plotlevels <- c('Strongly Agree', 'Agree', 'Neutral', 'Disagree', 'Strongly Disagree') | |
| tryCatch({ | |
| lbad <- likert(dataset) | |
| }, error=function(e) { | |
| print("This is good that an error was thrown!") | |
| print(e) | |
| }) | |
| sapply(dataset, class) | |
| sapply(dataset, function(x) { length(levels(x)) } ) | |
| for(i in seq_along(dataset)) { | |
| dataset[,i] <- factor(dataset[,i], levels=plotlevels) | |
| } | |
| experimentdataset <- likert(dataset) | |
| # Do the actual plotting | |
| likert.bar.plot(experimentdataset) | |
| # Close and write the file | |
| dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment