Note that there are some explanatory texts on larger screens.

plurals
  1. POCorrect for missing values in a Stacked area plot using ggplot2
    text
    copied!<p>I've been trying to recreate this <a href="http://groups.google.com/group/ggplot2/browse_thread/thread/594d6d321da7043e" rel="nofollow">post</a> on a combination of stacked bar/area plot. I have some problems with missing values though. </p> <p>Here's my data: <a href="https://www.dropbox.com/sh/pnkspwnn1qslm6u/JapTKCwqMS" rel="nofollow">https://www.dropbox.com/sh/pnkspwnn1qslm6u/JapTKCwqMS</a></p> <p>What I run is;</p> <pre><code> wa=read.table('wa_class.txt', sep="", header=F, na.string="0") names(wa)=c("Class","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") wam=melt(wa) wam$variablen=as.numeric(wam$variable) </code></pre> <p>How it looks like </p> <pre><code> &gt; head(wam) Class variable value variablen 1 Actinobacteria Jan 38.115163 1 2 Flavobacteria Jan NA 1 3 Sphingobacteria Jan 3.640469 1 4 Alphaproteobacteria Jan 13.631663 1 5 Betaproteobacteria_b28 Jan 3.718671 1 6 Betaproteobacteria Jan 14.732354 1 ggplot(na.omit(wam[,c("Class","value","variablen")]), aes(wam,x=variablen, y=value, fill=Class)) + geom_area(color="black") + geom_linerange(aes(ymax=value), position="stack") + scale_x_continuous(breaks=1:max(wam$variablen)) + labs(title="Water", x="Month", y="Relative abundance (%)") </code></pre> <p>...so I have tried to correct for the missing values with use na.omit on the variables I plot. However, I get layers in the plot which e.g. is overriding each other (see dropbox folder).</p> <p>I found this post (see dropbox folder) which corrected for it, but seemed only to have one. And I couldn't reproduce it since the link to the data is dead.</p> <p>Any help would really be appreciated!</p> <p>Thanks,</p> <p>Jo</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload