r - Error when adding vertical lines in ggplot2 -


so, i've got large dataset (around 400 000 observations) of data auctions. i'm trying use ggplot plot auction prices day, while denoting year color , month using vertical lines.

i have posixlt vector holds dates, here i'm working with:

firstmonth<- c(1,32,60,91,121,152,182,213,244,274,305,335)  require(ggplot2) p <- ggplot(bb, aes(saledate$yday, saleprice)) p <- p + geom_point(aes(color = factor(saledate$year)), alpha = i(1/30)) #this plot works p + geom_vline(aes(xintercept = firstmonth)) error in data.frame(xintercept = c(1, 32, 60, 91, 121, 152, 182, 213,  :    arguments imply differing number of rows: 12, 401125 

what's error? why can't vertical lines?

you need pass new data.frame geom_vline:

library(ggplot2)  bb <- data.frame(saleprice=rnorm(1000)) saledate <- data.frame(yday=1:1000,year=rep(1:10,each=100))  firstmonth<- c(1,32,60,91,121,152,182,213,244,274,305,335)  p <- ggplot(bb, aes(saledate$yday, saleprice)) p <- p + geom_point(aes(color = factor(saledate$year))) #this plot works p + geom_vline(aes(xintercept = firstmonth)) #error df2 <- data.frame(firstmonth) p + geom_vline(data=df2,aes(xintercept = firstmonth)) #works 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -