I have the following very simple R script which uses zoo to visualize daily numbers on a timeline:
# Small script to plot daily number of added users to database
library(zoo)
data <- read.csv("search_history.csv", header=FALSE)
# last line will be cut because it might be incomplete
zoodata <- data[1:(length(data$V2)-1), ]
series <- zoo(zoodata$V2, zoodata$V1)
par(mar=c(7, 6, 4, 2),
lab=c(5, 6, 5),
mgp = c(4, 1, 0))
plot(series,
main="Number of users added to database over time",
xlab="Date",
ylab="Number of users",
las=2,
lwd=2,
col="red",
cex.axis=0.7)
Content of search_history.csv:
"2012-12-27","458","4728"
"2012-12-28","239","6766"
"2012-12-29","193","8189"
"2012-12-30","148","7698"
"2012-12-31","137","7370"
"2013-01-01","119","6324"
"2013-01-02","122","7016"
"2013-01-03","115","7986"
"2013-01-04","112","8222"
"2013-01-05","112","6828"
"2013-01-06","124","7318"
"2013-01-07","121","8228"
"2013-01-08","120","8158"
...
I want to visualize the first (V1) and the second column (V2). I basically have two problems: The first and obvious one are the dashed lines at y-Position ~50 and ~450. How can I remove them and why are they even included?
The second problem is the inclusion of 2013-01-26 in the x-Axis. As you can see, I removed the last line of the dataset which contains this data (like an amateur, maybe there is a better way to do this). So the plot should not include the last date. I don't understand why it even knows about this date since it takes zoodata
as input, not data
.