You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The graphs have to be in 4 separate .PNG files. I cannot evaluate your work, as it all looks cut and pasted together. The graphs look correct, but the colors are off in plot4. Thanks.
`
setwd("C:/Users/qianm/Desktop/Project") ##Please set your own working directory where your data file is
plotData <- read.table("household_power_consumption.txt", header=T, sep=";", na.strings="?")
finaldata <- plotData[plotData$Date %in% c("1/2/2007","2/2/2007"),]
SetTime <-strptime(paste(finalData$Date, finalData$Time, sep=" "),"%d/%m/%Y %H:%M:%S")
finalData <- cbind(SetTime, finalData)
finalData <- plotData[plotData$Date %in% c("1/2/2007","2/2/2007"),]
SetTime <-strptime(paste(finalData$Date, finalData$Time, sep=" "),"%d/%m/%Y %H:%M:%S")
finalData <- cbind(SetTime, finalData)
`
hist(finalData$Global_active_power, col="red", main="Global Active Power", xlab="Global Active Power (kilowatts)")
plot(finalData$SetTime, finalData$Global_active_power, type="l", col="black", xlab="", ylab="Global Active Power (kilowatts)")
columnlines <- c("black", "red", "blue") labels <- c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3") plot(finalData$SetTime, finalData$Sub_metering_1, type="l", col=columnlines[1], xlab="", ylab="Energy sub metering") lines(finalData$SetTime, finalData$Sub_metering_2, col=columnlines[2]) lines(finalData$SetTime, finalData$Sub_metering_3, col=columnlines[3]) legend("topright", legend=labels, col=columnlines, lty="solid")
labels <- c("Sub_metering_1","Sub_metering_2","Sub_metering_3") columnlines <- c("black","red","blue") par(mfrow=c(2,2)) plot(finalData$SetTime, finalData$Global_active_power, type="l", col="green", xlab="", ylab="Global Active Power") plot(finalData$SetTime, finalData$Voltage, type="l", col="orange", xlab="datetime", ylab="Voltage") plot(finalData$SetTime, finalData$Sub_metering_1, type="l", xlab="", ylab="Energy sub metering") lines(finalData$SetTime, finalData$Sub_metering_2, type="l", col="red") lines(finalData$SetTime, finalData$Sub_metering_3, type="l", col="blue") legend("topright", bty="n", legend=labels, lty=1, col=columnlines) plot(finalData$SetTime, finalData$Global_reactive_power, type="l", col="blue", xlab="datetime", ylab="Global_reactive_power")
The text was updated successfully, but these errors were encountered: