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
27 lines (15 loc) · 916 Bytes
/
plot1.R
File metadata and controls
27 lines (15 loc) · 916 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
fileUrl <- "https://d396qusza40orc.cloudfront.net/exdata%2Fdata%2Fhousehold_power_consumption.zip"
download.file(fileUrl, destfile = "gastoElec.zip")
unzip("gastoElec.zip")
hpcLines <- readLines("household_power_consumption.txt"),
days_1_2 <- grep("^[12]/2/2007", substr(hpcLines, 1,8))
tbl_1_2 <- read.table(text=hpcLines[days_1_2], sep = ";",
stringsAsFactors = FALSE )
var_names = c("Date", "Time", "Global_active_power",
"Global_reactive_power", "Voltage",
"Global_intensity", "Sub_metering_1",
"Sub_metering_2", "Sub_metering_3")
names(tbl_1_2) <- var_names
with(tbl_1_2, hist(Global_active_power, col = "red",
main = "Global Active Power",
xlab = "Global Active Power (kilowatts)" ))