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
#Plot 1 Global Active Power
library(data.table)
plot1<-fread("household_power_consumption.txt")
subset<-plot1[plot1$Date %in% c("1/2/2007","2/2/2007"),]
png("Plot1.png", width=480, height=480)
hist(as.numeric(subset$Global_active_power), col="red", main="Global Active Power", xlab="Global Active Power (Kilowatts)")
dev.off();
#Plot 2
library(data.table)
plot2<-fread("household_power_consumption.txt")
mydata<-plot2[plot2$Date %in% c("1/2/2007","2/2/2007"),]
datetime<-strptime(paste(mydata$Date,mydata$Time, sep=" "),"%d/%m/%Y %H:%M:%S")
png("plot2", width=480, height=480)
plot(datetime, mydata$Global_active_power,xlab="",ylab="Global Active Power (Killowatts)",type="l")
dev.off()
#Plot 1 Global Active Power
library(data.table)
plot1<-fread("household_power_consumption.txt")
subset<-plot1[plot1$Date %in% c("1/2/2007","2/2/2007"),]
png("Plot1.png", width=480, height=480)
hist(as.numeric(subset$Global_active_power), col="red", main="Global Active Power", xlab="Global Active Power (Kilowatts)")
dev.off();
#Plot 2
library(data.table)
plot2<-fread("household_power_consumption.txt")
mydata<-plot2[plot2$Date %in% c("1/2/2007","2/2/2007"),]
datetime<-strptime(paste(mydata$Date,mydata$Time, sep=" "),"%d/%m/%Y %H:%M:%S")
png("plot2", width=480, height=480)
plot(datetime, mydata$Global_active_power,xlab="",ylab="Global Active Power (Killowatts)",type="l")
dev.off()
#Plot 3
library(data.table)
plot3<-fread("household_power_consumption.txt")
subsetdata<-plot3[plot3$Date %in% c("1/2/2007","2/2/2007"),]
DateTime<-strptime(paste(subsetdata$Date, subsetdata$Time, sep=" "),"%d/%m/%Y %H:%M:$S")
png("Plot3",width=480,height=480)
plot(DateTime,subsetdata$Sub_metering_1,xlab="",ylab="Energy sub metering",type="l")
lines(DateTime,subsetdata$Sub_metering_2,col="red")
lines(DateTime,subsetdata$Sub_metering_3,col="blue")
legend("topright",col=c("black","red","blue"),legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
dev.off()
#Plot 4
library(data.table)
plot4<-fread("household_power_consumption.txt")
subsetdata<-plot4[plot4$Date %in% c("1/2/2007","2/2/2007"),]
DateTime<-strptime(paste(subsetdata$Date, subsetdata$Time, sep=" "),"%d/%m/%Y %H:%M:%S")
png("plot4.png",width=480,height=480)
par(mfrow=c(2,2))
plot(DateTime,subsetdata$Global_active_power,xlab="",ylab="Global Active Power",type="l")
plot(DateTime,subsetdata$Voltage,xlab="DateTime",ylab="Voltage",type="l")
plot(DateTime,subsetdata$Sub_metering_1,xlab="",ylab="Energy sub metering",type="l")
lines(DateTime,subsetdata$Sub_metering_2,col="red")
lines(DateTime,subsetdata$Sub_metering_3,col="blue")
legend("topright",col=c("black","red","blue"),legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
plot(DateTime,subsetdata$Global_reactive_power,xlab="",ylab="Global_reactive_power",type="l")
dev.off()
The text was updated successfully, but these errors were encountered: