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 (22 loc) · 965 Bytes
/
Copy pathplot1.R
File metadata and controls
27 lines (22 loc) · 965 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
#this R script creates the first plot of Exploratory Data Analysis assigment
# we set the working path in which we have the data
myPath <- getwd()
pathWithData <-
file.path(myPath, "ExData_Plotting1") #path where I have the data
dataFile <-
file.path(pathWithData, "household_power_consumption.txt")
#we read the data from data file in our path
#we only read the data from 2007-02-01 and 2007-02-02 so we jump to that position in the file and read all data from these days
data <-read.table(dataFile,
skip = 66637,
nrow = 2880,
sep = ";")
#we read colunm names
namesList <- sapply(read.table(dataFile, nrow = 1, sep = ";"), as.character)
names(data)<-namesList
#histogram of first plot
with(data, hist(Global_active_power,
xlab = "Global Active Power (kilowatts)",
main = "Global Active Power", col = "red"))
dev.copy(png,'plot1.png')
dev.off()