I have a dataframe of which two columns are of date and sales. date column varies from 2012-10-22 to 2016-09-22. I want to plot the graph of sales in jan 2013 by day without creating any subset.
I have used this- ggplot(subsales,aes(Date,spdby))+geom_line()
Is it possible by using ggplot()?
I have plotted the sales per day and look like this-
I want to zoom in, to January 2013 and want to extract that part as a new plot.
yes, in ggplot:
library(ggplot2)
subsales <- data.frame(
date = seq(as.Date("2013-1-1"), as.Date("2017-1-1"), by = "day"),
spdby = runif(1462, 2000, 6000)
)
ggplot(subsales, aes(date, spdby)) +
geom_line()
ggplot(subsales, aes(date, spdby)) + geom_line() +
scale_x_date(limits = c(as.Date("2013-1-1"), as.Date("2013-1-31")))
#> Warning: Removed 1431 rows containing missing values (geom_path).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.