From 8d895ed2e7202cbe9135976db4d1e64e5b741ade Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Mon, 9 Apr 2012 16:02:49 -0400 Subject: [PATCH] fixed errors (x-png > x.png | missing 2nd png(~~~) | non-hardcoded input) --- analysis.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/analysis.R b/analysis.R index aadc02e..14efe89 100644 --- a/analysis.R +++ b/analysis.R @@ -1,7 +1,7 @@ -qcat("\n","Enter textfile name","\n") # prompt +cat("\n","Enter textfile name","\n") # prompt y<-readLines(n=1) -x <- "lord-hobo-cambridge.txt" +x <- paste(y,".txt", sep="") d <- read.csv(x)[,c(1,2,3)] colnames(d) <- c("rating", "day.of.week", "day.in.review") @@ -20,8 +20,8 @@ d\$day.of.week <- factor(d\$day.of.week, levels = c("Monday","Tuesday","Wednesday" d\$day.of.week <- as.factor(d\$day.of.week) -t <- table(d\$day.of.week, as.factor(d\$rating)) -t2 <- prop.table(t,2) +#t <- table(d\$day.of.week, as.factor(d\$rating)) +#t2 <- prop.table(t,2) chisq.test(d\$day.of.week, as.factor(d\$rating)) # compute and add a set of weights so that we can graph proportions @@ -34,7 +34,7 @@ d <- merge(d, w, by="day.of.week", all.x=TRUE, all.y=FALSE) library(ggplot2) # generate the unscaled count graph -filename.count <- paste(y,"-count-png",sep="") +filename.count <- paste(y,"-count.png",sep="") png(filename.count, width=8, height=6, unit="in", res=200) p <- qplot(day.of.week, data=d, fill=as.factor(rating), geom="bar", main=y) @@ -45,10 +45,10 @@ print(p) dev.off() # generate the scaled proportion graph -filename.prop <- paste(y,"-proportion-png",sep="") +filename.prop <- paste(y,"-proportion.png",sep="") max.value <- tapply(d\$plot.weight, d\$day.of.week, sum)[1] - +png(filename.prop, width=8,height=6, unit="in", res=200) p <- qplot(day.of.week, data=d, fill=as.factor(rating), geom="bar", weight=plot.weight, main=y) p <- p + scale_x_discrete("Day of Week") + -- 2.30.2