Skip to content

Commit 2491535

Browse files
committed
Create plot1.R
1 parent 73fe5c6 commit 2491535

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plot1.R

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plot1<- function(){
2+
library(data.table)
3+
#Reading the data from 01/o2/2007 to 02/02/2007
4+
col.names<- c("Date","Time","Global_active_power","Global_reactive_power","Voltage","Global_intensity","Sub_metering_1","Sub_metering_2","Sub_metering_3")
5+
data<- read.table("household_power_consumption.txt",sep=";",skip=66637,nrows = 2879,na.strings="?")
6+
data<- data.table(data)
7+
old<- c("V1","V2","V3","V4","V5","V6","V7","V8","V9")
8+
setnames(data,old,col.names)
9+
10+
11+
#Plotting the Histogram of Global_active_power
12+
hist(data$Global_active_power,col="red",xlab="Global Active Power (Kilowatts)",main="Global Active Power")
13+
14+
#Saving the histogram to plot1.png file
15+
dev.copy(png,file= "plot1.png")
16+
dev.off()
17+
}

0 commit comments

Comments
 (0)