Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Assignment #1 #751

Open
Qianmoyu opened this issue Jan 9, 2017 · 1 comment
Open

Project Assignment #1 #751

Qianmoyu opened this issue Jan 9, 2017 · 1 comment

Comments

@Qianmoyu
Copy link

Qianmoyu commented Jan 9, 2017

`

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)

`
plot1

hist(finalData$Global_active_power, col="red", main="Global Active Power", xlab="Global Active Power (kilowatts)")

plot2

plot(finalData$SetTime, finalData$Global_active_power, type="l", col="black", xlab="", ylab="Global Active Power (kilowatts)")

plot3

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")

plot4

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")

@acornelio0
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants