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
22 lines (18 loc) · 965 Bytes
/
plot2.R
File metadata and controls
22 lines (18 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#plot2
# For Coursera > Exploratory data analysis > Week 1 > project
# Danz 171112
#Clean up shop
rm(list=ls()) #remove all vars
cat("\014") #clear console
# Set working dir
setwd("C:\\Users\\adanz\\Dropbox\\Danz Cloud\\classwork\\Data Science - Coursera\\4 Exploratory data analysis\\week 1\\project\\ExData_Plotting1")
# Read data
df <- read.table("C:\\Users\\adanz\\Dropbox\\Danz Cloud\\classwork\\Data Science - Coursera\\4 Exploratory data analysis\\week 1\\project\\household_power_consumption.txt",
header=TRUE, sep = ';', stringsAsFactors=FALSE, dec=".")
# extract data for 2 days
dfSubset <- df[df$Date %in% c("1/2/2007","2/2/2007") ,]
# create plot
png("plot2.png", width=480, height=480)
dateNum <- strptime(paste(dfSubset$Date, dfSubset$Time, sep=" "), "%d/%m/%Y %H:%M:%S")
plot(dateNum, as.numeric(dfSubset$Global_active_power), type="l", xlab="", ylab="Global Active Power (kilowatts)")
dev.off()