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
33 lines (26 loc) · 839 Bytes
/
plot1.R
File metadata and controls
33 lines (26 loc) · 839 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
33
read <- function()
{
fn <- "household_power_consumption.txt"
df <- read.csv(fn,
as.is = T,
dec = '.',
sep = ";",
na.strings = "?",
skip = 66636,
nrows = 2880,
col.names = c("Date","Time", "Global_AC", "Global_RC", "V", "Global_Int","Sub_1","Sub_2", "Sub_3"),
colClasses = c("character", "character", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))
df$DateTime <- strptime(paste(df$Date, df$Time),"%d/%m/%Y %H:%M:%S")
df
}
createPlot1 <- function()
{
df <- read()
hist(df$Global_AC,
main = "Global Active Power",
xlab="Global Active Power (kilowatts)",
col = "Red"
)
dev.copy(png, file="plot1.png")
dev.off()
}