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
18 lines (14 loc) · 635 Bytes
/
plot1.R
File metadata and controls
18 lines (14 loc) · 635 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# plot1.R
# read in the column names, skip to the needed date
# and read in the data for the specified time period
df <- read.table("household_power_consumption.txt",
skip = 66637, nrow = 2880, sep = ";",
col.names = colnames(read.table(
"household_power_consumption.txt",
nrow = 1, header = TRUE, sep=";")))
# open a png file
png("plot1.png")
# plot the histogram of Global_active_power in the png file
hist(df$Global_active_power, col = "red", xlab = "Global Active Power (kilowatts)", main = "Global Active Power")
# close the graphic device
dev.off()