forked from rdpeng/ExData_Plotting1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.R
More file actions
15 lines (12 loc) · 739 Bytes
/
Copy pathplot2.R
File metadata and controls
15 lines (12 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Import data, then keep only 2 days of the data
powerData <- read.csv("data/powerData.txt",header=TRUE,sep=";",stringsAsFactors = FALSE)
powerData$Date <- as.Date(powerData$Date, format="%d/%m/%Y")
partialPowerData <- powerData[(powerData$Date >= "2007-02-01") & (powerData$Date <= "2007-02-02"),]
# Make DateTime column
partialPowerData$DateTime <- as.POSIXct(paste(partialPowerData$Date, partialPowerData$Time, sep=" "))
# Convert used column to numeric
partialPowerData$Global_active_power <- as.numeric(partialPowerData$Global_active_power)
# Make plot
x.label <- ""
y.label <- "Global Active Power (kilowatts)"
plot(x = partialPowerData$DateTime, y = partialPowerData$Global_active_power, type="l", xlab = x.label, ylab = y.label)