forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot1.R
More file actions
21 lines (17 loc) · 774 Bytes
/
plot1.R
File metadata and controls
21 lines (17 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
##
## Course 4 - Peer Graded Assignment: Course Project 1
## Plot 1 - A simple histogram of Global Active Power
require(tidyr)
require(dplyr)
## Read Data
columnClass <- rep("numeric", 9)
columnClass[1] = "character"
columnClass[2] = "character"
data <- read.csv("household_power_consumption.txt", header = TRUE, sep = ";", na.strings = "?", colClasses = columnClass)
## Filter and transform data
data <- filter(data, Date %in% c("1/2/2007", "2/2/2007")) %>%
mutate(Date = as.Date(Date, "%d/%m/%Y")) ## Convert Date field to Date format
## Plot a simple histogram of Global Active Power
png(filename = "plot1.png", width = 480, height = 480)
hist(data$Global_active_power, col = "red", xlab = "Global Active Power (killowatts)", main = "Global Active Power")
dev.off()