forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot1.R
More file actions
15 lines (14 loc) · 718 Bytes
/
plot1.R
File metadata and controls
15 lines (14 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
data <- read.csv ( "household_power_consumption.txt", sep = ";" , header= TRUE, stringsAsFactors = FALSE, na.strings = "?")
data$dttm <- paste(data$Date , data$Time , sep = " " )
data$conversion <- strptime( data$dttm , format="%d/%m/%Y %H:%M:%S")
data[,3] <- as.numeric(data[,3])
data[,4] <- as.numeric(data[,4])
data[,5] <- as.numeric(data[,5])
data[,6] <- as.numeric(data[,6])
data[,7] <- as.numeric(data[,7])
data[,8] <- as.numeric(data[,8])
data[,9] <- as.numeric(data[,9])
x <- data[data$Date == "1/2/2007" | data$Date == "2/2/2007", ]
png ( filename="plot1.png" , width=480, height=480)
hist(x$Global_active_power, col = "red", xlab = "Global Active Power(killowatts)" , main = "Global Active Power")
dev.off()