Skip to content

Commit 15c5436

Browse files
committed
and plot2
1 parent 78a4efc commit 15c5436

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

plot2.R

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
power <- read.csv( "household_power_consumption.txt", sep = ";", na.strings = c("?") )
3+
4+
# head(power)
5+
# Date Time Global_active_power Global_reactive_power Voltage
6+
# 1 16/12/2006 17:24:00 4.216 0.418 234.84
7+
# Global_intensity Sub_metering_1 Sub_metering_2 Sub_metering_3
8+
# 1 18.4 0 1 17
9+
10+
# "We will only be using data from the dates 2007-02-01 and 2007-02-02."
11+
12+
# "Add the PNG file and R code file to your git repository"
13+
14+
# "Construct the plot and save it to a PNG file with a width of 480 pixels and a height of 480 pixels."
15+
# this seems to be the default.
16+
17+
power$timestamp = as.POSIXct(paste0(power$Date, " ", power$Time), format="%d/%m/%Y %H:%M:%S")
18+
19+
power <- power[ power$timestamp >= as.POSIXct("2007-02-01") & power$timestamp < as.POSIXct("2007-02-03"), ]
20+
21+
png(file = "plot2.png", width = 480, height = 480, units = "px")
22+
23+
plot( power$timestamp, power$Global_active_power, ylab = "Global Active Power (kilowatts)", xlab="", type="l" )
24+
25+
dev.off()
26+
27+
28+

plot2.png

15.6 KB
Loading

0 commit comments

Comments
 (0)