forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
32 lines (20 loc) · 723 Bytes
/
plot2.R
File metadata and controls
32 lines (20 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Week 1, Course Project 1
# set working dir
setwd("~/R Projects/Coursera/04_ExpDataAnalysis/Week 1")
# load data
df <- read.table("household_power_consumption.txt", sep=";", header=TRUE, na.strings = "?")
df$DateTime <- strptime(paste(df$Date, df$Time), "%d/%m/%Y %T", tz="GMT")
# subset the data to 2007-02-01 to 2007-02-02
set <- subset(df, as.Date(DateTime)>="2007-02-01" & as.Date(DateTime)<="2007-02-02")
## Plot #2
# plot of Global Active Power over time
png("plot2.png",
width = 480,
height = 480,
units = "px")
plot(x = set$DateTime,
y = set$Global_active_power,
type="l",
xlab="",
ylab="Global Active Power (kilowatts)")
dev.off()