Quando eseguo il plot utilizzando geom_area()
, mi aspetto che funzioni molto come geom_bar()
, ma sono un po 'perplesso da questo comportamento per i valori mancanti.Come posso fare in modo che geom_area() lasci uno spazio per i valori mancanti?
require(dplyr)
require(ggplot2)
set.seed(1)
test <- data.frame(x=rep(1:10,3), y=abs(rnorm(30)), z=rep(LETTERS[1:3],10)) %>% arrange(x,z)
# I also have no idea why geom_area needs the data.frame to be sorted first.
test[test$x==4,"y"] <- NA
ggplot(test, aes(x, y, fill=z)) + geom_bar(stat="identity", position="stack")
Produce questo grafico a barre in pila.
Tuttavia, se si passa a stack_area() interpola tra i valori mancanti.
> ggplot(test, aes(x, y, fill=z)) + geom_area(stat="identity", position="stack")
Warning message:
Removed 3 rows containing missing values (position_stack).
Se aggiungo in na.rm=FALSE
o na.rm=TRUE
non fa alcuna differenza.
ggplot (test, AES (x, y, z = riempire)) + geom_area (stat = "identità", Posizione = "stack", na.rm = TRUE) messaggio Attenzione: Eliminato 3 righe contenenti valori mancanti (position_stack)
ggplot (test, AES (x, y, riempire = z)) + geom_area (stat = "identità", posizione = "stack", na .rm = FALSE) Messaggio di avviso: Rimosso 3 righe trovare valori mancanti (position_stack).
Ovviamente, tutto ciò che sto cercando non funziona. Come posso mostrare un vuoto nella serie con stack_area()
?
seguente problema: http://stackoverflow.com/questions/35454277/can-you-make-geom-ribbon-leave-a-gap-for-mi sso a ip-valori? answertab = i voti # tab-top – eFF