# Exploratory data analysis¶

## Course Project 1.¶

In [1]:
%load_ext rmagic

In [10]:
%%R
colClasses=c('character', 'character', 'numeric', 'numeric', 'numeric',
'numeric', 'numeric', 'numeric', 'numeric'))

# select only two days 2007-02-01 and 2007-02-02
d = d[(d$Date == '1/2/2007') | (d$Date == '2/2/2007'),]

# convert date
d$Date = as.Date(d$Date, "%d/%m/%Y")


## Plot 2¶

In [14]:
%%R
with(d,
plot(DateTime, Global_active_power, type='l', ylab='Global Active Power (kilowatts)', xlab=''))


## Plot 3¶

In [16]:
%%R
with(d, {
plot(DateTime, Sub_metering_1, type='l', col='black', ylab='Energy sub metering', xlab='', ylim=c(0,38))
lines(DateTime, Sub_metering_2, type='l', col='red')
lines(DateTime, Sub_metering_3, type='l', col='blue')
legend('topright', c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3'), lty=1, col=c('black', 'red', 'blue'))
}
)


## Plot 4¶

In [17]:
%%R
par(mfrow=c(2,2))
with(d,{
plot(DateTime, Global_active_power, type='l', ylab='Global Active Power', xlab='')
plot(DateTime, Voltage, type='l', xlab='datetime')

plot(DateTime, Sub_metering_1, type='l', col='black', ylab='Energy sub metering', xlab='')
lines(DateTime, Sub_metering_2, type='l', col='red')
lines(DateTime, Sub_metering_3, type='l', col='blue')
legend('topright', c('Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3'), lty=1, col=c('black', 'red', 'blue'), bty='n')

plot(DateTime, Global_reactive_power, type='l', xlab='datetime')
})