Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
17 lines (17 loc) · 981 Bytes

File metadata and controls

17 lines (17 loc) · 981 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
plot1 <- function ( ) {
## Set to the correct working directory
setwd("~/Desktop/Exploratory Data Analysis/Project 1")
## Read household_power_consumption.txt data
powerData <- read.csv("household_power_consumption.txt",header=TRUE,sep=";",na.strings = "?", colClasses = "character")
## Clean up data, by fixing data and time format and subsetting only the dates to analyze
powerData$Date <- as.Date(powerData$Date, format="%d/%m/%Y")
powerData$Time <- as.POSIXct(powerData$Time,format="%H:%M:%S")
smallPowerData <- subset(powerData,subset=(Date < "2007-02-03"))
smallPowerData <- subset(smallPowerData, subset=(Date > "2007-01-31"))
## Create a histogram for Global Active Power data, use red bars
hist(as.numeric(smallPowerData$Global_active_power),col="red",xlab="Global Active Power (kilowatts)",main = "Global Active Power")
## Copy plot to png
dev.copy(png, file = "plot1.png")
## Close connection
dev.off()
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.