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 (18 loc) · 790 Bytes
/
plot1.r
File metadata and controls
21 lines (18 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#Plot1
#Exploratory Data Analysis
#Joseph Chatman
#retrieve data
data.source <- read.table("household_power_consumption.txt", comment.char= "", sep= ";", na.strings= "?", skip= 66600, n= 3050)
#convert data into a data frame
data <- data.frame(data.source)
#subset for dates required
segment <- subset(data, as.Date(V1) == '01/02/2007' | as.Date(V1) == '02/02/2007')
#perform date and time conversions
date <- as.character(segment$V1)
time <- as.character(segment$V2)
date.time <- paste(date, time)
date.time <- strptime(date.time, "%d/ %m/ %Y %H: %M: %S")
#create the hisogram
png(file = 'plot1.png')#open PNG device and create plot1.PNG
hist(segment$V3,xlab= "Global Active Power (kilowatts)", col ="red", main="Global Active Power")
dev.off()#close PNG device in my working directory