Skip to content

Commit 5b1b71a

Browse files
author
pdiazs
committed
Create plot1.R
1 parent 73fe5c6 commit 5b1b71a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

plot1.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Read and review the data
2+
household_power_consumption <- read.csv("G:/R/Coursera Explora/exdata_data_household_power_consumption/household_power_consumption.txt", sep=";")
3+
View(household_power_consumption)
4+
str(household_power_consumption)
5+
## Transform Data into Active power into numeric
6+
household_power_consumption$Global_active_power<-as.numeric(as.character(household_power_consumption$Global_active_power))
7+
## Transform Date into Date class variable
8+
household_power_consumption$Date <- strptime(household_power_consumption$Date, "%d/%m/%Y")
9+
## Subset Variables
10+
sub.hpcs = subset(household_power_consumption, as.Date(Date) >= '2007-02-01'& as.Date(Date)< '2007-02-03')
11+
12+
## Check histogram
13+
hist(sub.hpcs$Global_active_power, col="red", xlab="Global Active Power (kilowatts)", main="Global Active Power")
14+
## Save final png
15+
16+
png('plot1.png',width = 480, height = 480)
17+
hist(sub.hpcs$Global_active_power, col="red", xlab="Global Active Power (kilowatts)", main="Global Active Power")
18+
dev.off()

0 commit comments

Comments
 (0)