forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot2.R
23 lines (21 loc) · 1.11 KB
/
plot2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Ploting 2
rm(list=ls()) # Clear workspace
# Working directory
setwd('/home/sirjoy/Dropbox/CursosRecibidos/Coursera/ExploratoryDataAnalisis_Coursera_2014/Project1/')
# Dates of interest start in line 69518 until 66637
data <- scan(file = 'household_power_consumption.txt', sep = ';', skip =66637,
nlines = 2881, na.strings='?', what = list(character(), character(),
double(),double(),double(),double(),double(),double(),double()))
data <- as.data.frame(data)
colnames(data) <- c('Date','Time','Global_active_power','Global_reactive_power','Voltage',
'Global_intensity','Sub_metering_1','Sub_metering_2','Sub_metering_3')
# Transform dates
data$Date <- as.character(data$Date)
data$Time <- as.character(data$Time)
data$Fecha <- paste(data$Date, data$Time)
data$Fecha <- strptime(data$Fecha, '%d/%m/%Y %H:%M:%S')
Sys.setlocale("LC_TIME", "en_US.UTF-8") # Days in english
par('mfrow' = c(1,1))
plot(data$Fecha, data$Global_active_power, type='l', ylab='Global Active Power (kilowatts)', xlab='')
dev.copy(png, file = "plot2.png")
dev.off()