1

I've been trying to recreate this post on a combination of stacked bar/area plot. I have some problems with missing values though.

Here's my data: https://www.dropbox.com/sh/pnkspwnn1qslm6u/JapTKCwqMS

What I run is;

    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)

How it looks like

    > 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 (%)")

...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).

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.

Any help would really be appreciated!

Thanks,

Jo

2
  • I wonder why you start with Mar in your script. Hence, the data is not identical to what you post here. Commented Oct 12, 2012 at 8:36
  • Oh, forgot to change that in the post. It It should of course start with Jan and so on... Now corrected for. Thanks! Commented Oct 12, 2012 at 11:33

1 Answer 1

0

One solution is to read zeros as zero values. If you don't use na.string="0", the plot will look like this:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.